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

Error: Failed to load 'http://localhost:8082/create_session' #284

Closed
besarthoxhaj opened this issue Feb 26, 2016 · 23 comments

Comments

Projects
None yet
@besarthoxhaj
Copy link

commented Feb 26, 2016

When running the application on dev mode from my phone I get the following error

Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://localhost:8082/create_session'

If I run the same code on the simulator it works fine.

@alazier

This comment has been minimized.

Copy link
Contributor

commented Feb 26, 2016

Another user hit this here #276. Are you also on android? If so does running adb forward tcp:8082 tcp:8082 fix the issue for you?

@besarthoxhaj

This comment has been minimized.

Copy link
Author

commented Feb 27, 2016

Hi @alazier I'm using iOS on mac. Is there some other thing I can do?

@alazier

This comment has been minimized.

Copy link
Contributor

commented Feb 27, 2016

There is definitely an issue at the moment running debug mode on the device. We have an rpc server running on the device/simultor to serve api calls when in debug mode - when running on the device chrome is trying to hit localhost rather than the server on the device which fails.

You may be able to hardcode your devices IP address to work around the issue. You can change this by editing the DEVICE_HOST url in node_modules/realm/lib/rpc.js. I haven't tested this yet so let us know if this works. We will look into ways of doing this automatically.

@besarthoxhaj

This comment has been minimized.

Copy link
Author

commented Feb 27, 2016

I just tried to change DEVICE_HOST to both:

DEVICE_HOST = '<IP-ADDRESS>:8081';
// and
DEVICE_HOST = '<IP-ADDRESS>:8082';

but I still get the same error Failed to load 'http://<IP-ADDRESS>:8082/create_session'

Do I need to change it somewhere else as well?

@alazier

This comment has been minimized.

Copy link
Contributor

commented Feb 27, 2016

Not sure as I haven't had the chance to try this out yet. Will give it a try later today.

@besarthoxhaj

This comment has been minimized.

Copy link
Author

commented Feb 27, 2016

Thanks @alazier and also thanks for bringing Realm in react-native!:)

@alazier

This comment has been minimized.

Copy link
Contributor

commented Feb 29, 2016

I was able to get chrome debugging working by changing the ip address as described above as well as following the instructions for getting chrome debugging working on device from the react native docs. The steps I took:

  • Changed localhost in Appdelegate.m to the computer's IP address
  • From this page https://facebook.github.io/react-native/docs/debugging.html I made this change:
    On iOS - open the file RCTWebSocketExecutor.m and change localhost to the IP address of your computer. Shake the device to open the development menu with the option to start debugging.
  • I changed const DEVICE_HOST in node_modules/realm/lib/rpc.js to use the device IP address.

If you continue to get the same error most likely the device IP address you are using is incorrect.

appden added a commit that referenced this issue Mar 1, 2016

Use device IP addresses to connect to RPC host
It still only tries localhost for the simulator, but for devices, we now get a list of possible IP addresses to attempt to connect to before throw a more helpful exception.

Resolves #284 and fixes #276

@appden appden self-assigned this Mar 1, 2016

appden added a commit that referenced this issue Mar 1, 2016

Use device IP addresses to connect to RPC host
It still only tries localhost for the simulator, but for devices, we now get a list of possible IP addresses to attempt to connect to before throw a more helpful exception.

Resolves #284 and fixes #276
@besarthoxhaj

This comment has been minimized.

Copy link
Author

commented Mar 2, 2016

Sorry for the delay guys, will try this as soon as I got time, hopefully later today.

@appden appden added S:Review and removed S:In Progress labels Mar 3, 2016

@shtefanntz

This comment has been minimized.

Copy link

commented Mar 3, 2016

Would this be the cause for the first error here? -> #303

@alexcurtis

This comment has been minimized.

Copy link

commented Mar 5, 2016

I am also getting this error with iOS simulator. React Native 0.21.
I have the packager running on a non-standard port (9081)

@jwhitley

This comment has been minimized.

Copy link

commented Mar 5, 2016

I'm also getting this in the iOS simulator, React Native 0.20.0. I am using the Chrome Debugger. The packager is listening on port 8081.

@leijing7

This comment has been minimized.

Copy link

commented Mar 11, 2016

I had this error on iOS device and simulator with RN. I found out that I accidentally drag RealmJS.framework to the Embedded Binaries section but not the RealmReact.framework. Fixed this then the error was gone.

@arconamagi

This comment has been minimized.

Copy link

commented Mar 12, 2016

@leijing7 Thanks! You saved my time!
I had the same problem and I also dragged RealmJS.framework instead of RealmReact.framework. Now, all works fine for me.

@ Realm developers: thank you for your work!
I suggest to add this problem & its solution to F.A.Q. troubleshooting section..

@alexcurtis

This comment has been minimized.

Copy link

commented Mar 12, 2016

double checked and definitely got RealmReact.framework in the embedded binaries. Everything works fine when chrome debugging isn't enabled. But as soon as it is -- I get this issue.

@appden

This comment has been minimized.

Copy link
Contributor

commented Mar 13, 2016

@alexcurtis is this only on device for you, or in simulator as well?

@alexcurtis

This comment has been minimized.

Copy link

commented Mar 13, 2016

@appden I've only tested on the simulator. React Native 0.21. I have the packager running on a non-standard port (9081)

@paldepind

This comment has been minimized.

Copy link

commented May 9, 2017

I've had issues with debugging and Realm for a long time. It used to work in the emulator but now I can't debug at all. Of course, that is a huge dealbreaker as debugging is essential.

Is there any chance this will get fixed? Because otherwise, I'm afraid I'll have to replace Realm with another database.

@agersoncgps

This comment has been minimized.

Copy link

commented May 12, 2017

I hit this today runing iOS simulator on Mac.

POST http://localhost:8082/call_method net::ERR_EMPTY_RESPONSE

@dev10

This comment has been minimized.

Copy link

commented Jul 7, 2017

For me (I am using Expo) the actual reason that this is occurring is that it is being blocked by CORS because the origins don't match

To bypass this problem on the iOS simulator, I am using this workaround to turn off CORS in Chrome:

  1. Close Chrome if it is already open
  2. open -a Google\ Chrome --args --disable-web-security --user-data-dir

Hope that helps anyone stuck on this same issue.

@appden
First complete error from Chrome console:

XMLHttpRequest cannot load http://localhost:8082/create_session. 
The 'Access-Control-Allow-Origin' header has a value 'http://localhost:8081' that is not equal to the supplied origin. 
Origin 'http://localhost:19001' is therefore not allowed access.
makeRequest @ rpc.js:196

As you can see it requesting port 8082 in the XMLHttpRequest, but the server is supposed to be running on port 8081 but is actually on port 8082. The above snippet is a bit confusing, I know :-)

Full request headers from Chrome for create_session:

General:
Request URL:http://localhost:8082/create_session
Request Method:POST
Status Code:200 OK
Remote Address:[::1]:8082
Referrer Policy:no-referrer-when-downgrade

Response Headers:
Access-Control-Allow-Origin:http://localhost:8081
Cache-Control:no-cache
Connection:Close
Content-Length:12
Content-Type:application/json
Date:Fri, 07 Jul 2017 10:42:09 GMT
Server:GCDWebServer

Request Headers:
Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:52
Content-Type:text/plain;charset=UTF-8
Host:localhost:8082
Origin:http://localhost:19001
Referer:http://localhost:19001/debuggerWorker.js
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
@Looveh

This comment has been minimized.

Copy link

commented Aug 30, 2017

Why is this issue closed? It seems like many are still encountering this problem.

I run into this when starting up an app with remote debugging on a device through Bluetooth State Restoration, which makes it impossible to debug Bluetooth functionality in our case.

@ThierryVC

This comment has been minimized.

Copy link

commented Dec 1, 2017

I am developing with react-native and I've had this problem for a while
I just fixed this by running
react-native install realm (I used yarn before)
and
react-native link realm

@sumantimalsina9

This comment has been minimized.

Copy link

commented Dec 25, 2017

I am also facing this problem in my ios simulator and can not find solution anywhere. Can someone help me please?

@bdash

This comment has been minimized.

Copy link
Contributor

commented Dec 25, 2017

Please file a new issue rather than commenting on an issue that's been closed for 18 months. In your new issue, be sure to include all of the information that's requested in the new issue template.

@realm realm locked and limited conversation to collaborators Dec 25, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.