Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not running at all. SignalR error: Undefained #14

Closed
dabor238 opened this issue Jan 10, 2017 · 18 comments
Closed

Not running at all. SignalR error: Undefained #14

dabor238 opened this issue Jan 10, 2017 · 18 comments

Comments

@dabor238
Copy link

I try to use this package, but the following error appears. Any help would be really appreciated.

My server info is:
var connection = signalr.hubConnection('https://www.multidoctores.com');
var proxy = connection.createHubProxy('chatHub');

This info is already tasted in Web, Android and Ios native apps.

screen shot 2017-01-10 at 3 33 26 pm

screen shot 2017-01-10 at 3 34 26 pm

@olofd
Copy link
Owner

olofd commented Jan 10, 2017

Anything related to #12?

@dabor238
Copy link
Author

I don't think that is the same issue, because:

  1. the server is HTTPS
  2. the hub has no security, you can access it here: https://www.multidoctores.com/signalr/hubs

@dabor238
Copy link
Author

Do I have to configure the hub in any specific way to test the library. Do you have an example of a server side hub that actually works with this library?

@dabor238
Copy link
Author

It tries to negotiate with

[16:41:33 GMT-0500 (ECT)] SignalR: Negotiating with 'https://www.multidoctores.com/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D'.

that brings a valid token. but then it gives us the
SignalR error: undefined.

@olofd
Copy link
Owner

olofd commented Jan 10, 2017

Testing now. Hold on.

@olofd
Copy link
Owner

olofd commented Jan 10, 2017

@dabor238 I get:
"An SSL error has occurred and a secure connection to the server cannot be made."
Sry. There is a bug in the lib that hides the actual error.

@olofd
Copy link
Owner

olofd commented Jan 10, 2017

But do this:
Start react-native with chrome dev tools.
Go to sources tab and press cmd + O (mac) ctrl + O (windows) and search for the file ajax.js and open it.
should look like this:


export default function(options, data) {
  var request = new XMLHttpRequest();
  request.onreadystatechange = (e) => {
    if (request.readyState !== 4) {
      return;
    }

    if (request.status === 200 && !request._hasError) {
      options.success && options.success(JSON.parse(request.responseText));
    } else {
      options.error && options.error(request);
    }
  };

  request.open(options.type, options.url);
  request.setRequestHeader('content-type', options.contentType);

  request.send(options.data.data && `data=${options.data.data}`);
  
  return {
    abort: function(reason) {
      return request.abort(reason);
    }
  };
}

Place a breakpoint at options.error and then inspect your error.

@olofd
Copy link
Owner

olofd commented Jan 10, 2017

Now for the error itself I do not know what's wrong exactly. You have any idea?

@olofd
Copy link
Owner

olofd commented Jan 10, 2017

I now connected successfully to your server by disabling NSAppTransportSecurity..Hmm don't really know why it won't connect without it.

added

  <key>NSAppTransportSecurity</key>
   <dict>

      <key>NSAllowsArbitraryLoads</key>
      <true/>

   </dict>

to Info.plist.

@dabor238
Copy link
Author

screen shot 2017-01-10 at 5 24 42 pm

_response: An SSL error has occurred and a secure connection to the server cannot be made.

No idea why this happened, we are using this hub on WEB, Native Android and Native Ios, and it works fine.

@dabor238
Copy link
Author

I added at the end and still doesnt work.

screen shot 2017-01-10 at 5 30 49 pm

screen shot 2017-01-10 at 5 32 56 pm

@olofd
Copy link
Owner

olofd commented Jan 10, 2017

Hmm.. might be incorrectly formated.

This i my entire Info.plist in XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
      <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationLandscapeLeft</string>
      <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string/>
    <key>NSAppTransportSecurity</key>
   <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
   </dict>
  </dict>
</plist>

Try opening yours in xcode and see if it can open it.

@dabor238
Copy link
Author

olofd: the boy wonder, the kid, the miracle man. the phenomenon, the unstoppable. It Works.

screen shot 2017-01-10 at 5 43 36 pm

@olofd
Copy link
Owner

olofd commented Jan 10, 2017

Haha 👍 Happy to help out. But I will take a look at two things:

  1. Why you need that Info.plist edit (will also make a mention about these issues in the readme)
  2. That undefined error-value needs fixing.

Will do that in the next couple of days when I have time.

But let me know if there is anything else and good luck with your project!

@dabor238 dabor238 reopened this Jan 10, 2017
@dabor238
Copy link
Author

My dear friend.

look at this http://stackoverflow.com/questions/32495059/ios9-will-nsallowsarbitraryloads-true-be-allowed-for-a-release-in-the-app-store

It appears that this fix will couse some problems for a release in the app store.

@olofd
Copy link
Owner

olofd commented Jan 10, 2017

@dabor238 I found the root issue.
Your server uses TLS 1.0. Insecure.
So it was refused. You should look at upgrading.

However. You can do this, and set an exception for your domain only to accept TLS1.0.
This should have no problem in App Store. (Even though the other version with allowing all is no prob. either, have released multiple apps with it.)

Here is the Info.plist with the exception:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>en</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIdentifier</key>
	<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>$(PRODUCT_NAME)</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>1</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIRequiredDeviceCapabilities</key>
	<array>
		<string>armv7</string>
	</array>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UIViewControllerBasedStatusBarAppearance</key>
	<false/>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string></string>
	<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsArbitraryLoads</key>
		<false/>
		<key>NSExceptionDomains</key>
		<dict>
			<key>localhost</key>
			<dict>
				<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
				<true/>
			</dict>
			<key>www.multidoctores.com</key>
			<dict>
				<key>NSTemporaryExceptionMinimumTLSVersion</key>
				<string>TLSv1.0</string>
			</dict>
		</dict>
	</dict>
</dict>
</plist>

@olofd olofd closed this as completed Jan 10, 2017
@olofd olofd reopened this Jan 11, 2017
@dabor238
Copy link
Author

Thank so much for the information

@olofd
Copy link
Owner

olofd commented Jan 14, 2017

@dabor238 FYI: I've just released 0.0.11 on npm. I should contain a fix for the undefined error-problem you faced earlier. Please update and let me know if something is not working. Have you had any other issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants