socketIO DAT URL formatting

I am running node.js and socket.io and have setup a very basic system to send messages from my browser to io.emit(). This all works great. I can see the messages coming into my server and all connected clients including the sender.

I’d like to connect Touch. The socketIO DAT seems like it should be the way to go but I can’t figure out how to format the URL. Seems like I should need to tell it the path to the server but I have no idea how to format that.

My server and clients will be different machines in the end. Currently I am on one machine. I’ve tried http://localhost:port but that isn’t getting me anything.

That format looks correct to me. If the server is secure then you’ll need to use https or wss instead though.

The SocketIO DAT prints connection status messages to the console, which could provide some insight. You can enable the console in TouchDesigner by setting the environment variable TOUCH_TEXT_CONSOLE=1, then the console will appear next time you open TD.

It’s likely that it’s a protocol version issue. The SocketIO DAT is still on v2.x for compatibility reasons, so the server will need to be configured to accept v2 connections. In node.js there is an allowEIO3 (engineio=3 for socketio v2) for socketio v3 servers, but I’m not sure if that still exists in v4: Socket.IO 3.1.0 | Socket.IO – allowEIO3 needs to be set to true.

1 Like

I am still struggling.

I am seeing a “Client Connected” response when I Activate/Deactivate the socket.io DAT but I am still getting nothing coming in as far as data.

I have tried to add this but it did nothing:

const io = new Server(server, {
allowEIO3: true //false by default
});

What am I doing wrong??

index.zip (470 Bytes)
HTML Test.toe (5.3 KB)

You have to define which events you want to listen to.

2 Likes

How do I know what the events are? I just want to send a number…

The socketio event name is what you pass as the first argument to the emit method, and you need to put these event names in the DAT’s second input to listen for them. In your case that looks to be just: “chat message”.

1 Like

Oh you’re my hero. I’ve been struggling with this for days. I am able to do a ton of really cool things by picking apart the Operator Snippets but there isn’t one for this. So many parts to get this working… this was the last piece of the puzzle! Thank you so much!!

I am guessing that by “You can enable the console in TouchDesigner by setting the environment variable TOUCH_TEXT_CONSOLE=1, then the console will appear next time you open TD.” you are saying I can have TD start with the console open by default? Is that basically the same as splitting the window and opening Text Ports and DATs (F9)? Or does changing the env-vars add something extra you don’t get by going through the interface?

Thanks again! Roadblock defeated!

Between you and eric.b the two of you have saved me. Thank you so much!