Need some help posting to Socket.IO server

Hi everyone!

I’ve been using rasa for a chatbot that i want to use within Unity. I’m using the Socket.IO input channel to host a local server. The server is working fine! I can get info from it and talk to the chatbot via command line. But when i try to post to the server from my Unity client i get an unknown/generic error. I’ve tried to post to /webhooks/socketio/webhook & /webhooks/rest/webhook and some other ones that i could find in code examples and the documentation.

As you can probably tell, i haven’t been using python and rasa all that long. Can anyone help me out? I’d like to know which address to post to and in what format.

Thanks!

Can you post this on the rasa core repo with more details about what error you’re getting and what commands you’re running things with etc

The code i was using was not working correctly. I discovered it after making various socket.io clients and servers. With and without rasa.

Found a nice package on github that works instead. For anyone reading this, it’s not entirely plug-and-play. Its very bare-bones and eg. doesn’t disconnect the client properly when exiting the program.

Client repo: https://github.com/floatinghotpot/socket.io-unity

Hello Mark, i am trying to use Socket.io too but i am kinda stuck. Do not find the Documentation that describes how to establish a connection with Socketio Server . Are there more examples on this? Thanks and and all the best

have just started on that endeavor as well – did you have any pointers as this is an old thread? I’ve looked through the docs (which I think are wrong as they mention accessing the sockets via http://localhost:5005/ instead of something like ws://localhost:5005.

Is it necessary to use the mr. bot AI widget to get it working properly with Rasa?

@niveK no it’s not necessary to use the mrbot widget, it’s just an already implemented widget you can use if you want.

What are you stuck with?

I was able to get things fixed, but I had to avoid using websockets for now.

I believe the first call is correct; it should first establish connection via http://localhost:5005/ or whatever the root server URI is, because the websocket client will handle creating the connection itself.

Thanks again @akelad!

1 Like

Hey @niveK. We have similiar issue as you. We got it working with http and transport=polling, but even though we are using mr.bot webchat ui, it never switches to WS protocol. I.e. it never upgrades the protocol, and just runs continuous long polling. So everything works, but ONLY with long poll.

@akelad Do you know if the socketio.py channel supports upgrading to WS protocol? Or is is it only long polling? i.e. endless loop of HTTP GET/POST?

We tested Mr.Bot reach chat widget against a generic socket.io node server and we can see that it starts with HTTP get/post pair as @niveK mentioned. And then it sends an upgrade request header and polling stops and it’s working over websocket connection.

But with the rasa back end, it stays long polling.

Can you clarify what is supported?

I’m currently on Rasa core 0.13.1 (or 0.13.2) on Ubuntu 16.04, Pyton 3.6.8.

Thank you.

+1

Hi Serge,

I have the exact same problem. Only long-polling is used in the mrbot chat <> socketio setup. I had a look into the python-socketio package that Rasa uses in their connector, but couldnt yet really figure out which other library it is using in the backend for deployment or how it interacts with flask. Maybe this needs to be adjusted. As you say, some clarification here would help.

@Serge Hi, can you provide solution that get it working? How you change transport?

Hi @Nick_Kazakov. I couldn’t get it working with Rasa 0.13.x but once I upgraded to 1.1.x it worked out of the box:

'upgrades': ['websocket'], 'pingTimeout': 60000, 'pingInterval': 25000}
2019-06-26 02:40:55 DEBUG    rasa.core.channels.socketio  - User 5d0291399f154a20ad71821d110f40a4 connected to socketIO endpoint.
2019-06-26 02:40:55 INFO     engineio.server  - 5d0291399f154a20ad71821d110f40a4: Sending packet MESSAGE data 0
2019-06-26 02:40:55 INFO     engineio.server  - 5d0291399f154a20ad71821d110f40a4: Received packet MESSAGE data 2["session_request",{"session_id":"9d8cbef69c684feaa7d14e9bd4bab060"}]
2019-06-26 02:40:55 INFO     socketio.server  - received event "session_request" from 5d0291399f154a20ad71821d110f40a4 [/]
2019-06-26 02:40:55 INFO     socketio.server  - emitting event "session_confirm" to 5d0291399f154a20ad71821d110f40a4 [/]
2019-06-26 02:40:55 INFO     engineio.server  - 5d0291399f154a20ad71821d110f40a4: Sending packet MESSAGE data 2["session_confirm","9d8cbef69c684feaa7d14e9bd4bab060"]
2019-06-26 02:40:55 DEBUG    rasa.core.channels.socketio  - User 5d0291399f154a20ad71821d110f40a4 connected to socketIO endpoint.
2019-06-26 02:40:55 INFO     engineio.server  - 5d0291399f154a20ad71821d110f40a4: Received request to upgrade to websocket
2019-06-26 02:40:55 DEBUG    websockets.protocol  - undefined - state = CONNECTING
2019-06-26 02:40:55 DEBUG    websockets.protocol  - undefined - event = connection_made(<TCPTransport closed=False reading=True 0x5f5b908>)
2019-06-26 02:40:55 DEBUG    websockets.protocol  - undefined - state = OPEN
2019-06-26 02:40:55 DEBUG    websockets.protocol  - undefined < Frame(fin=True, opcode=1, data=b'2probe', rsv1=False, rsv2=False, rsv3=False)
2019-06-26 02:40:55 DEBUG    websockets.protocol  - undefined > Frame(fin=True, opcode=1, data=b'3probe', rsv1=False, rsv2=False, rsv3=False)
2019-06-26 02:40:55 DEBUG    websockets.protocol  - undefined < Frame(fin=True, opcode=1, data=b'5', rsv1=False, rsv2=False, rsv3=False)
2019-06-26 02:40:55 INFO     engineio.server  - 5d0291399f154a20ad71821d110f40a4: Upgrade to websocket successful 

It worked over ws and wss too, as I have apache 2.4 with certificate, and all seems fine now. So try the latest rasa core (read upgrade manual as it’s a little different and hopefully all works for you as well) :cowboy_hat_face:

2 Likes

glad you got it figured out!

can you tell me how can i use socket.io in rasa i want to connect my webchat to rasa i dont know how to do that please help.

hi @ymehta1 if you get the answer please tell me i can’t figure out how to do this either

@ymehta18 @SallemiDorsaf here’s the link to connecting a bot that way: Your Own Website

hi @akelad the steps are not clear and i’m stuck with an error for 2 weeks

what are you stuck with specifically?