socketio / socket.io-client-cpp

C++11 implementation of Socket.IO client
MIT License
2.25k stars 726 forks source link

Can't make handshake with flask-socketio server (QT-MSVS14-x64) #166

Open esacape3d opened 7 years ago

esacape3d commented 7 years ago

I'm not a professional programmer, but I need to build a software communicating between QT gui and Raspberry PI. I've implemented a Flask-SocketIO server on RPi and looking for a QT client implementation. I've downloaded the example code and built it. It's working and connected to the server, but it keeps showing an error about handshaking. It seems like the server expects 'transport=polling', but the example code always sends 'transport=websocket'. Tried to set the server to explicitly receive polling, but it does not work. Searched for the solution for couple of hours and saw the author of the Flask-socketIO said it does not support websocket. Hmm. then is it possible to send via transport=polling with QT client? That seems the only solution for now. Or do I need to use other server platform besides Flask-socketIO? Thanks in advance.

bethnull commented 7 years ago

Hi esacape3d, did you find any solution regarding this incompatibility?

I'm in the same scenario as you.

Thanks in advance.

bethnull commented 7 years ago

Hi again!

Today I've successfully tested python-socketio with socket.io-client-cpp, it supports the websocket transport.

So initially, I can confirm that a flask app combined with python-socketio and the socket.io-client-cpp works.

BR, beth.

esacape3d commented 7 years ago

Hello Beth,

Yes, that was also my conclusion that socket.io-client-cpp can't communicate with Flask-socketio server due to the mismatched protocols. It only support websocket so you may need to use other servers that support the websocket. Glad to hear that you've found python-socketio worked! Thanks for the information.

Best regards, Yun

eric-tc commented 5 years ago

Hi was you able to send back data from flask python to c++ with the h.socket()->on() function? Can you explain me how to do this. I am able to send data from c++ client to flask server but i cannot receive back any data with socket-on() function in c++ from python flask. Thanks

jAndriolli commented 5 years ago

Hi Eric

I can send and receive messages to/from a nodejs server using socket c++.

I used the example from Melo Yao from 3/24/15. You can find it at: https://github.com/comaeio/socket.io-client-cpp11-non-boost/blob/master/examples/Console/main.cpp. This is also the example that is in the example/console that comes with the git clone of the socket c++.

Try it! I can assure you that it works! You can also find relevant information in GitHub.

Best Regars Jose Luiz Andriolli Pereira

José Luiz Andriolli Pereira

On Thu, Mar 7, 2019 at 4:13 PM eric notifications@github.com wrote:

Hi was you able to send back data from flask python to your c++ with the h.socket()->on() function? Can you explain me how to do this. I am able to send data from c++ client to flask server but i cannot receive back any data with socket-on() function in c++ from python flask. Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/socketio/socket.io-client-cpp/issues/166#issuecomment-470564690, or mute the thread https://github.com/notifications/unsubscribe-auth/As_9hP43UhWPEQXInrbXaRmLNw49Sz2jks5vUSybgaJpZM4N6UbG .

pampas93 commented 5 years ago

@jAndriolli Could you explain more on the solution for connecting it with a simple node server hosted locally. I still get the following error when I try to run the console example application (If I use this or the non-boost project)

[2019-03-30 19:37:34] [connect] Successful connection
[2019-03-30 19:37:40] [error] Server handshake response error: websocketpp.processor:20 (Invalid HTTP status.)
Connection failed.

Using socket.io on node.js creates a http based server. Should I make any changes to the current example console app to connect to it?

rthickling commented 4 years ago

I get the same problem. Any info welcome!