I am Newbie to SocketCluster i had install the socketcluster with help of link
http://socketcluster.io/#!/docs/getting-started
I am able to communicate with server through browser console as given in above link.But i want the python as client.
So for this i try using SocketIO pacakage. Following is my code
from socketIO_client import SocketIO
with SocketIO('localhost', 8000) as socketIO:
socketIO.emit("ping", {message: ' object with a message property'})
But i am getting error as
No handlers could be found for logger "socketIO_client"
So i want to know how to communicate with SocketCluster server with python as client
The Socket.io client is not protocol-compatible with the SocketCluster server. SC sockets do share a similar API as Socket.io though. There is no Python client for SC at the moment.
Related
I implemented a Flask SocketIO server using Flask-SocketIO 5.3.2 and it is working well when I test it using a JavaScript client even from different origin. But when I try to connect to the server using Postman SocketIO, I am getting Error: Unexpected server response: 400 in Postman and Flask Server is logging SocketIO 400 Error. Attached are screenshots from both Postman Response and Server logs.
Server Logs:
Postman Response:
The reason was that the flask built in development server was using polling whereas postman client was using websocket. So I configured websocket for the server using gevent and resolved the issue. You can get more information about this from this discussion Reddit Thread, this is where I got the idea.
I've developed a WebApp with Flask, where different threads check a status and, if something changes they send a new json to the client. Then the client, with the javascript, can update the html page.
Running the app in my LAN, different clients connect and everything work correctly.
If I run the app on a real server (such as AWS, by using "flask run --host=0.0.0.0" ), the clients can connect and show the web page, but they don't receive the json sent by the socket of the webapp.
In the WebApp, a thread sends the new json by calling a function that uses:
socketio.emit('update', {'number': new_json_FE}, namespace='/test')
While the javascript receives this message (and does something) in this way:
socket.on('update', function(msg) { ....}
It is very strange that the clients connected in the LAN receive correctly all the json sent by the socket, while in the web not: they only receive the json when they connect to, and I have to upload the page (they don't receive the socket messages).
Can you help me?
Thank you very much!
I would advise against the use of threads like you have described for this situation.
Instead I would probably create a new program, StatusUpdater, that is always running and which is connected via socket to your Flask-SocketIO backend. When it finds a change in status it sends w/e signal or payload it needs to, through a socket, to the Flask-Socketio server. The SocketIO server upon receipt of this StatusUpdater payload can then send a broadcast to all connected clients notifying the client of the update.
I currently have a requirement where I'll need my Django server to establish a connection to a 3rd party provider (via sockets) and listen for events. The 3rd party uses TCP to send/receive messages and requires me to do some socket programming to integrate their services.
What I think is supposed to happen:
Django server acts as client socket, 3rd party server will send messages to my Django server and I'll have to appropriately decrypt each message and have respective functions to handle those messages.
Things I'm confused about:
The correctness of this setup / architecture.
Where to place code in Django so that when I run python manage.py runserver my python socket code will execute (the socket.connect($HOSTNAME, $PORT) step)
I can´t connect to my server which I built at the AWS instance using the client code I wrote in Postman. My server is running. I can send messages from my postman app to my friend´s server in another instance. Also they can send me messages from their client code to my server.It´s just I can´t connect to my instance. Where could be the problem? Again, my server is running fine and answers to other requests.
This is the client side code in Postman. What could be the problem here? Thank you!
I have written a client application in C++ using websockets in Unix Environment trying to connect a Node.js/Socket.IO server running in a LAN connectivity. I found the server application is not responding at all. I tried a couple of other options from client side eventually getting no response from the server. Basically, i am trying to send a JSON object to the system running SocketIO server, but the client is not getting connected even if the server listens on to a Port.
Help, is really appreciated. Thank you.
Make sure following has been checked-
Server running and port is open (firewall) - Client is unable to connect the server
Url is correct - Client is unable to connect or url not exist
Listener code or receiving task is running - Client connected but when server send data to client, client didnot receive data
JSON format is correct and json data does not contain invalid character - client send data server but server did not received
Follow -
remove date if exists into msg for test purpose, use " to prepare JSON data, donot put / end of the url if not required. example-
1. Write url as ws://abc.com:8080/wsserver
2. JSON data as {"name":"myname","yourname":"indo","msg":"birthday"}