Websocket

143 views
Skip to first unread message

posty

unread,
Dec 4, 2013, 10:49:46 AM12/4/13
to comman...@googlegroups.com
Trying to get a websocket at the CF end to work with a node js socket.io server.  Keep getting the message 'debug: destroying non-socket.io upgrade' from the node.js end.  I assume this is when they try and connect but no connection event is firing.  Anyone got a code example of both the server and the client that might show how to do it?  I know from a prior post Florent you have done this but I can't get it to work.......

Regards

Simon
**Please include as much software version information as possible. This ensures that other users and CommandFusion staff can provide a helpful answer as quickly as possible.** - Please Delete this line BEFORE posting.

Florent Pillet

unread,
Dec 4, 2013, 3:30:19 PM12/4/13
to comman...@googlegroups.com
We use WebSockets internally, but don't support them at this point for GUIs running in the iViewer environment. I'm not surprised that this doesn't work at all -- HTTP requests initiated by CF.request() are single shot only.

Florent

posty

unread,
Dec 4, 2013, 6:08:28 PM12/4/13
to comman...@googlegroups.com
I must be being dense since there is a thread already on this forum where you state you do.  I think you even state you have tested a websocket to socket.io and it works fine.  What did I miss?  The code you posted is below:

Yes you can, but don't use CF.request() if you want to use true websockets. 

Instead, use the actual HTML5 websocket interface that you can access from your 
iViewer Javascript code. It is the exact same interface that you use from HTML pages, 
therefore you can do a: 

        var socket = new WebSocket("ws://192.168.0.100"); 
        socket.onopen = function() { 
                // your code here 
        }; 
        socket.onmessage = function(msg) { 
                // process received data here 
        }; 
        socket.onclose = function() { 
                // process close here 
        }; 
        socket.onerror = function(err) { 
                // process error here 
        }; 


Florent 



Simon

Florent Pillet

unread,
Dec 5, 2013, 2:09:22 AM12/5/13
to comman...@googlegroups.com
That's why I should stay away from answering questions - can't even remember what I tried and what I didn't :)

I'm not sure why you are getting this message from socket.io though. I'm not even sure you'd get the same error when running on device and when running in your desktop browser with the debugger. You'll have to look at the implementation details in the socket.io core to make sure.

Florent 

On 05 Dec 2013, at 00:08, posty <simon...@gmail.com> wrote:

I must be being dense since there is a thread already on this forum where you state you do.  I think you even state you have tested a websocket to socket.io and it works fine.  What did I miss?  The code you posted is below:

Yes you can, but don't use CF.request() if you want to use true websockets. 

Instead, use the actual HTML5 websocket interface that you can access from your 
iViewer Javascript code. It is the exact same interface that you use from HTML pages, 
therefore you can do a: 

        var socket = new WebSocket("ws://192.168.0.100"); 
        socket.onopen = function() { 
                // your code here 
        }; 
        socket.onmessage = function(msg) { 
                // process received data here 
        }; 
        socket.onclose = function() { 
                // process close here 
        }; 
        socket.onerror = function(err) { 
                // process error here 
        }; 



--
Florent Pillet - Software Engineering Lead



posty

unread,
Dec 5, 2013, 8:33:38 PM12/5/13
to comman...@googlegroups.com
Should anyone have interest, after various amounts of playing with different nodejs web socket implementations I have found that node-js websocket works when a web socket is open in CF per the code above.  Socket IO and other variant of web sockets of nodejs did not seem to like CF I am afraid.  However, nodejs websocket seems reasonably powerful and can both transmit to single instances as well as broadcast making it ideal for my nodes Sonos module!

There is however one hitch!  Only works in debugging mode presumably because the code is executing in the browser not the iPad.  Florent anything you could do to change that or is it an Apple thing?

Simon

YourMe

unread,
Dec 6, 2013, 10:37:15 AM12/6/13
to comman...@googlegroups.com
True, i had tried this also when trying to view a webserver with nodejs, only achieve success by running all iPads' iViewers in debugging mode.

Hope this is not the case as I used nodejs+iViewer integration for remote file/document viewing in iViewer app from a server, so iPads sleep mode was disable for loss of connections.

Regards.
Reply all
Reply to author
Forward
0 new messages