zeroasterisk / MeteorRider

PhoneGap/Cordova + Meteor integration approach "DOM hijacking", telling PhoneGap where to get content from, letting Meteor hijack your PhoneGap app's HTML/CSS/JS
MIT License
183 stars 28 forks source link

SockJS: ws:///sockjs connection failed #1

Closed strikeout closed 10 years ago

strikeout commented 11 years ago

Hi!

Loving your approach! Much faster rendering than the iframe approach while still relatively seperated!

I ran into a big problem tho.. the app cant connect to my meteor server via sockjs, the sockjs_url is always null (only on mobile devices and simulators). Debugging shows something like ws:///sockjs connection failed. My Server is reachable via network by IP (tested), phobegao is set to whitelist alll connections (*), I can run the app in mobile safari fine and I even set the ROOT_URL for meteor on the server environment to a reachable IP, to no avail.

I tried playing around with Meteor._defaultTransport and such to manually set the SockJS Url, no progress.

Can you give me a heads up please, would love to get this running!

zeroasterisk commented 11 years ago

I have this running on ios6, ios7, android 4.0.4, and android 4.1 devices. I've pointed them at the production (real) URL and at my local development machine's IP (obviously, not "localhost" since the devices aren't the ones running meteor).

I have not noticed the error you mentioned, sorry.

Can you provide more details? (exact error message, meteor version, phonegap version, device, does any part of the connection work, etc)

strikeout commented 11 years ago

phonegap v.3.1.0-0.15 meteor v. 0.6.6.1

there is no exact errror message, but if i remote-debug the ios devices (ipad, iphone, ios sim with ios6/7) with safari the network panel shows me 404's on "file:///sockjs/info?cb=sywx59yywc", everything else works flawlessly.

my guess is that it has something to do with the file:// prefix to the url.. Meteor.connection..sockJs.raw_url = "/" the network connection itself works fine, and if I do a window.location.href = "http://192.168.1.100:3000" in the webkit-console, it works perfectly as well.

here is the output of the console.log(data) from the meteor-rider $.ajax request:

013-10-17 00:06:38.225 myApp[23871:a0b] Finished load of: file:///Users/thomas/Library/Application%20Support/iPhone%20Simulator/7.0/Applications/976D434C-C0C4-4E80-8D63-7502C367CB90/myApp.app/www/index.html
2013-10-17 00:06:38.332 myApp[23871:a0b]   Received Event: deviceready
2013-10-17 00:06:38.332 myApp[23871:a0b]   MeteorRider success
2013-10-17 00:06:38.333 myApp[23871:a0b]   success
2013-10-17 00:06:38.333 myApp[23871:a0b]   http://192.168.1.100:3000
2013-10-17 00:06:38.333 myApp[23871:a0b]   <!DOCTYPE html>
<html>
<head>
    #lots includes#

    <script type='text/javascript'>__meteor_runtime_config__ = {"meteorRelease":"0.6.6.1","ROOT_URL":"http://192.168.1.100:3000","ROOT_URL_PATH_PREFIX":"","serverId":"bzzA2cvFHWJp5n34M","FILEHANDLER_SUPPORTED":true,"accountsConfigCalled":true};</script>

    #more includes#
strikeout commented 11 years ago

fixed it! The production deployment to someApp.meteor.com works flawlessly, but not the local dev. setup. For some reason I have to explicitly set the DDP_DEFAULT_CONNECTION_URL env. variable for it to work locally, so what I ended up with the following to get the local dev server started, maybe its of help for somebody:

$: DDP_DEFAULT_CONNECTION_URL="ddpi+sockjs://192.168.1.100:3000/sockjs" mrt
zeroasterisk commented 11 years ago

Wow - great find/fix (I am at work and so have been unable to look into it, sry)

Is there anything I can put into the script to fix this for local development?

If you'd like to submit a pull request to update the readme, please do so.

thanks!

raix commented 11 years ago

the };</script> in the html could be replaced with "DDP_DEFAULT_CONNECTION_URL":"http://192.168.1.100:3000"};</script>

Not sure if a wanted feature, but setting "serverId"="" will hinder hotcode push

zeroasterisk commented 11 years ago

Might be worth putting in as a comment at least...

zeroasterisk commented 10 years ago

Take a look at my readme enhancement #28 stating that Android doesn't have full WebSockets support without a plugin