hi, while trying to work with remote debugging (#562 and #571) i upgraded to rn 0.32 and now i'm seeing this when enabling the remote debugging:
Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://192.168.1.178:8082/create_session'.
i understand there's some issues with remote debugging. the ip address is the ip of the android device
With the latest [email protected] you need to run react-native link realm instead of rnpm when installing Realm. I believe this fixed the remote debugging issues on Android. We will update the docs to reflect this.
react-native link realm doesn't fix this issue
Are you seeing this issue with the latest RN version? Does everything work properly when running on the emulator/genymotion? Unfortunately we haven't yet had time to look into resolving the issues when running on android devices so debugging on the emulator is probably the best you can do for the time being.
Is this still an issue? Or is this actually causing problems? You would get this message if you quit simulator or your app while the chrome debug window is still running.
i'll try to test this soon and get back to you :)
}(:=
still have same issue at android device ..QQ
+1
+1
We are experiencing this same issue in the iOS simulator. Remote debugging just breaks for us.
Same issue here. Really need debugging on device to proceed with Realm.
+1
I'm experiencing this issue when rebooting an app in the background on iOS as triggered by CoreBluetooth state restoration, which unfortunately is a deal breaker for my team since state restoration is something we cannot do without in our product.
+1
+1 on android emulator
Received this while remote debugging via chord to my physical android device. The only operation I was trying to perform was a simple create. Was fixed by ending remote debugging. It seems to be flipping a quarter whether or not I'll get progress made when enabling remote debugging. I can't reliably reproduce the error, only the fix.
My guess is as follows.
Running on a device and debugging fails because normally adb forward tcp:8082 tcp:8082 takes care of the correct redirection from device to host.
Because you are debugging from chrome http://<ip-address>:8082/create_session is an invalid url.
I changed the following lines in node_modules/realm/lib/browser/rpc.js
// The global __debug__ object is provided by Visual Studio Code.
if (global.__debug__) {
let request = global.__debug__.require('sync-request');
let response = request('POST', url, {
body: JSON.stringify(data),
headers: {
"Content-Type": "text/plain;charset=UTF-8"
}
});
statusCode = response.statusCode;
responseText = response.body.toString('utf-8');
} else {
let body = JSON.stringify(data);
let request = new XMLHttpRequest();
request.open('POST', url, false);
request.send(body);
statusCode = request.status;
responseText = request.responseText;
}
to
// The global __debug__ object is provided by Visual Studio Code.
if (global.__debug__) {
let request = global.__debug__.require('sync-request');
let response = request('POST', url, {
body: JSON.stringify(data),
headers: {
"Content-Type": "text/plain;charset=UTF-8"
}
});
statusCode = response.statusCode;
responseText = response.body.toString('utf-8');
} else {
let body = JSON.stringify(data);
let request = new XMLHttpRequest();
// ALWAYS POINT TO LOCALHOST
if (__DEV__) {
url = 'http://localhost:8082' + url.substring(url.lastIndexOf('/'));
}
request.open('POST', url, false);
request.send(body);
statusCode = request.status;
responseText = request.responseText;
}
And now everything works fine (even when not debugging remotely)
I hope this helps
Selman555 thank you for answer. it worked for me. Now i can debug android in windows
+1: I'm getting this same issue - there doesn't seem to exist a /create_session endpoint on the metro bundler server.
Does this have something to do with an update in metro/react-native? Maybe the endpoint existed before and the name changed...is there a way to get insight into this issue?
I did some proper network redirection in my unconventional setup, for those who need it:
https://github.com/realm/realm-js/issues/1732#issuecomment-378385610
@Selman555 thank you for answer,but it doesn't work for me . Any other solutions for this issue? Please @me. Thanks a lot!
My guess is as follows.
Running on a device and debugging fails because normallyadb forward tcp:8082 tcp:8082takes care of the correct redirection from device to host.
Because you are debugging from chromehttp://<ip-address>:8082/create_sessionis an invalid url.I changed the following lines in
node_modules/realm/lib/browser/rpc.js// The global __debug__ object is provided by Visual Studio Code. if (global.__debug__) { let request = global.__debug__.require('sync-request'); let response = request('POST', url, { body: JSON.stringify(data), headers: { "Content-Type": "text/plain;charset=UTF-8" } }); statusCode = response.statusCode; responseText = response.body.toString('utf-8'); } else { let body = JSON.stringify(data); let request = new XMLHttpRequest(); request.open('POST', url, false); request.send(body); statusCode = request.status; responseText = request.responseText; }to
```
// The global __debug__ object is provided by Visual Studio Code.
if (global.__debug__) {
let request = global.__debug__.require('sync-request');
let response = request('POST', url, {
body: JSON.stringify(data),
headers: {
"Content-Type": "text/plain;charset=UTF-8"
}
});statusCode = response.statusCode; responseText = response.body.toString('utf-8');} else {
let body = JSON.stringify(data);
let request = new XMLHttpRequest();// ALWAYS POINT TO LOCALHOST if (__DEV__) { url = 'http://localhost:8082' + url.substring(url.lastIndexOf('/'));
in my case, debugging of physical device is working, but emulator it is not working
Im using React 0.55.4 just installed realm, Trying to debug an iOS build from a Mac
Facing the same issue, tried the fix above didn't work, everything seems to be working fine if I don't 'debug remotely', But I start getting these errors once I do try to debug remotely:
'Access to XMLHttpRequest at 'http://localhost:8081/create_session' from origin 'http://192.168.1.21:8081' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.'
'Must first create RPC session with a valid host'
'Unhandled JS Exception: Must first create RPC session with a valid host'
react: 16.6.3
react-native: 0.58.6
realm: 2.26.0
Also facing the same problem, must first create RPC session with valid host.
Debugging realm/lib/browser/rpc.js shows realm tries to sendRequest('create_realm'), but fails for some reason.
I fixed this error by using the fix specified by Selman55, only changing localhost:8082 to localhost:8083
in my case on iOS 12.2 (realm 2.26.1 and/or 2.28)
// ALWAYS POINT TO LOCALHOST
if (__DEV__) {
url = 'http://localhost:8082' + url.substring(url.lastIndexOf('/'));
}
or
...localhost:8083...
do not work.
App crashes on first launch after removing and re-installing app from the phone, on both Debug and Release builds.
Partly fixed by downgrade realm to 2.2.10 BUT it also contain this issue for iOS 12.2:
https://github.com/realm/realm-js/issues/2305
So without fork it is not possible to use realm in my project! "Nice" work :)
The issue with crashing app at the first launch has found!
It seems start from v2.23 there is a BUG in "/src/ios/platform.mm"
Here is missed ! sign in this IF:
if ([manager createDirectoryAtPath:docsDir withIntermediateDirectories:YES attributes:nil error:&error])
https://github.com/realm/realm-js/blob/master/src/ios/platform.mm#L78
therefore after deletion of app from device at first launch this IF returned TRUE and the
throw std::runtime_error(util::format("Failed to create directory \"%1\": %2", docsDir.UTF8String, error_description(error).UTF8String));
is fired and app crashes.
This bug was created by this commit:
https://github.com/realm/realm-js/commit/9c6d26aa591d33cd9161cd40f389da33c340ccda#diff-2c49b41809c315e7530a10428f8a80f5
and I surprised that noone still did not create a ticket about this :)
@ValeriiKov thank you! I found this issue by searching issues for "createDirectoryAtPath"
I am seeing crashes on iOS that adding missing not sign "!" fixes.
"react": "^16.8.6",
"react-native": "0.59.9",
"realm": "^2.28.1",
I would not have run into this issue if I had not needed to update to realm 2.28.1 for Android 64-bit support.
In the latest releases (v10.x) we have fixed multiple issues related to the Chrome debugger. I am closing this issue as create_session has been rewritten.
Most helpful comment
My guess is as follows.
Running on a device and debugging fails because normally
adb forward tcp:8082 tcp:8082takes care of the correct redirection from device to host.Because you are debugging from chrome
http://<ip-address>:8082/create_sessionis an invalid url.I changed the following lines in
node_modules/realm/lib/browser/rpc.jsto
And now everything works fine (even when not debugging remotely)
I hope this helps