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.
Related
I am using sails 0.12.14 version back-end with EmberJS 3.20 front-end. I am currently dealing with a websocket connection problem in production.
Using "sails.io.js": "^1.1.0", "socket.io-client": "^1.4.5" for sails compatibility in Ember ( same goes for sails back-end ).
Both servers are on AWS. When i use app in development (localhost), everything is OK, socket is connected, messages are pushed from back-end to fron-end via socket. But when i deploy Ember app to production, i get this:
WebSocket connection to 'ws://{my-page-domain}/socket.io/?__sails_io_sdk_version=1.1.0&__sails_io_sdk_platform=node&__sails_io_sdk_language=javascript&EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 400
Where is this comming from and why can't ember app access sails.io ? Back-end is running just fine.
Any idea what is happening ?
Any insight whatsoever is appreciated.
edit: i have found this Sails WebSocket connection to 'ws: but allowOnlyOrigins: [''] with my s3 bucket website endpoint point has no effect on this
SOLUTION:
edit2: if anyone struggles with the same error, it was a nginx setting i was missing.
https://stackoverflow.com/a/29232687/792724
I have a django application that I want to deploy using daphne.
Django application supports both websockets and http requests. I've converted the django to support ASGI.
I'm starting the server using :
daphne <project_name>.asgi:application
The server is able to accept websocket connections but unable to handle the incoming HTTP requests (throws 404).
Where am I going wrong over here?
P.S.: I'm not using django channels.
I had forgotten to instantiate 'get_asgi_application' while creating the django application. Hence, it wasn't able to accept HTTP requests.
I'm working with Django 2, Django Rest Framework, Vue and Docker on a rather simple CRUD SPA.
The basic CRUD functions are already working properly, but I'm constantly getting a long list of errors in the browsers developer console.
These are the errors:
WebSocket connection to 'ws://localhost:8000/sockjs-node/960/pxv3l3z5/websocket' failed: Error during WebSocket handshake: Unexpected response code: 200
POST http://localhost:8000/sockjs-node/960/mf1pj0yr/xhr_streaming?t=1558372142795 403 (Forbidden)
WebSocket connection to 'ws://localhost:8000/sockjs-node/124/3qg4rd5f/websocket' failed: Error during WebSocket handshake: Unexpected response code: 200
EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection.
They all seem to be related with a web socket issue, but I'm not actively using websockets. The app just issues a couple of requests to the Django Rest Framework backend.
So I really don't know what is causing these errors. Maybe I configured something wrong?
When I am running same url("http://localhost:4047/webServicesDemo/webapi/injectdemo/context") in tomcat configured in eclipse it it working fine. While getting 404 error every time in postman rest client.
Please put some light on it.
Thanks.enter image description here
Sometimes Apache does not work with other ports. You need to set the port of your google chrome in httpconfig file of Apache Server.
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.