facebook

socket.io doesn’t run on a remote app

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #333678 Reply

    ilsuocero
    Member

    Hi, and season greetings….
    I’m developing an app which uses socket.io for fetching some data from a remote MySql database.
    The app works perfectly in the mobione simulator. For using node.js Socket.io the client needs to link a remote javascript: in my case http://remote.server:3022/socket.io/socket.io.js and when I try to show the source, mobione test center shows me the right content of a remote socket.io.js.
    But….
    As soon as I publish the app, if I try to see the source of the socket.io.js, the test center shows me an empty page. The same beaviour happens in the iPhone because the app shows a error claim an undefined socket.io variable.
    Do you know where is the problem?
    Thanks a lot.
    Roberto

    #333701

    support-michael
    Keymaster

    @ilsuocero

    >As soon as I publish the app,

    I assume this is “Publish as Mobile Web Application”? If yes, then I strongly suspect the problem is same-origin violation. You can confirm this in the Test Center by enabling web security from the toolbar or the Browser menu>Web Security and testing your webapp. If it fails with web security enabled then the problem is isolated to the web same-origin policy. In a native app the same-origin policy is much less of an issue since the app’s web content is loaded from the local file system and not subject to this policy. Alternatively, you can enable CORRs support on your server.

    If no, then something else is goof’n up.

    #333702

    support-michael
    Keymaster

    I did a quick google and found references to other developers that have run into same-origin policy issues with socket.io, e.g., http://stackoverflow.com/questions/6770490/socket-io-basic-example-not-working

    #333706

    ilsuocero
    Member

    Yes, I confirm that I mean publish as mobile web app.
    Same behavior even with web security swithed off. In any case the web security was every time enabled in all my tests.
    I try to resume:

    1) app tested via test center calling the app with .mobi extention or calling the same .mobi app saved in the home screen: everything OK
    2) app published as web app and shown in the test center: socket.io.js is source now shown in the source section or in debug but when the socket.io function is called nothing happens
    3) app published as web app and saved in the home screen: error, can’t find variable: io (io is a variable of socket.IO)

    My question is: why theese different behavior?
    Thanks
    Roberto

    #333707

    ilsuocero
    Member

    Sorry, what is the CORRs support?
    regards
    Roberto

    #333709

    support-michael
    Keymaster

    Here’s some info http://enable-cors.org/

    #335290

    SimonB
    Member

    Roberto,

    did it work in the end? were you able to use socket.io from your phone?

    Thanks

    Simon.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: socket.io doesn’t run on a remote app

You must be logged in to post in the forum log in