Possible to run ofxLibwebsockets as client and connect to localhost?

I’m trying to get my OF app using the ofxLibwebsockets addon to connect to my localhost on port :4200 and am running into connection issues. I can connect to the echo.websockets.org example in the package but no dice for anything locally.

I have the host, protocol, port etc… etc set up however the only thing that I can see that might be causing the issue is the bUseSSL option. It formats the url that is making the request to xxx.xxx.x.xxx:4200/:0 when I set bUseSSL to false – since I’m not using SSL.

I’m running Node.js as my local server and I’m doing the websockets with Socket.io. I can also connect to my localhost from other web devices on the network using the localhost’s IP without an issue connecting to xxx.xxx.x.xxx:4200

The verbose log i’m getting from OF is

[verbose] [ofxLibwebsockets] connect: xxx.xxx.x.xxx:4200/:0
[verbose] [ofxLibwebsockets] Setting timeout 10
[verbose] [ofxLibwebsockets] LWS_CALLBACK_PROTOCOL_INIT
[verbose] [ofxLibwebsockets] libwebsocket init success
[verbose] [ofxLibwebsockets] LWS_CALLBACK_LOCK_POLL
[verbose] [ofxLibwebsockets] LWS_CALLBACK_ADD_POLL_FD
[verbose] [ofxLibwebsockets] LWS_CALLBACK_UNLOCK_POLL
[verbose] [ofxLibwebsockets] LWS_CALLBACK_LOCK_POLL
[verbose] [ofxLibwebsockets] LWS_CALLBACK_CHANGE_MODE_POLL_FD
[verbose] [ofxLibwebsockets] LWS_CALLBACK_UNLOCK_POLL
[verbose] [ofxLibwebsockets] Connection successfully created. Connecting.
[ error ] [ofxLibwebsockets] Connection error
on close

For the ofxLibwebsockets addon to work does it need to be connecting to a remote server like Heroku? And is there a way to remove the “/:0:” from the end of the url being requested in the plugin?

Any guidance would be awesome too!


Hi there,
I think the issue could be related to socket.io library. I have tried using a python based server and ofxLibwebSocket sample works fine. If I am not wrong, socket.io adds some abstractions such as channels/topics on top of the websocket api that this addon does not support.

Try with this simple python (2.7) module:

And as a test, change the port number for example_client_hello_world sample that comes with ofxLibWebsockets to 8000 and give it a try.

Mine is tested on Mac.
hope it helps

1 Like

Thanks for the background and suggestion of the simple websocket server. I was able to set up and get a basic prototype talking with ofxLibWebsockets without any issues. I might stick with python for this project.

As you suggested, the issue might be with socket.io. I’ll do some additional digging and see what i come up with when trying to use a nodejs stack.