I am running api using .net core web app, created a server with hub so i can send messages to a group of users or all of the users. Basically I use hubconnectionbuilder on the client side and it works, but want to create case for connecting only trough websockets from client side.
I already managed to connect to a server and subscribe to a hub, but can't figure out how to establish bi-directional communication.
Simply I don't get response from server, only sending messages not receiving anything from server.
Related
Normally the server-client communication works like this: the client sends some request (GET, DELETE, PATCH, etc) and the server responds client with some data. Is it possible to achieve that server sends the data to the client without the client sending request first?
To be more specific, I am wanting to build a chat room app. So when A sends a message to B, A will send a request to the server (together with that message), but B does know about this hence B does not want to request all of B's messages from the server. So how can B get notified in this case?
Without any information at all having been sent recently, this would only be possible if there's a reliable direct path to the client, and the client is also a server that can listen to requests. This approach will probably only work for clients with their own stable static IP addresses, and not from the average internet customer behind carrier-grade NAT.
But if the client can make an initial connection to the server when the client's app comes online - which is extremely typical of apps similar to what you're describing - you can set up a websocket connection at that point, allowing both the client and server to send information to each other.
Create a websocket connection to the server when the client comes online. Then, when the server sees a message change that it wants to communicate to clients, the server can iterate over all still-active websockets (or, if desired, only the still-active websockets that also need to update in response to the message), and send a message through each of them, and each connected client can see the message from the server.
I have used web-sockets on the client side but I am confused on how to build and communicate with web-socket server.
My application is in rails,from what I understood I need a separate web-socket server(preferably node).
I know how the communication happens from client to web-socket server but want to understand how will the communication from rails to node websocket server will happen?
My use case is like this -> any database operation -> inform to websocket-server-> inform to client
I can approach via hosted api's like pusher.js but want to approach of my own
Would request your help, if you think I am not approaching the right way?
I have a c++ server using WinSock2 sockets,
can I connect to this server using JavaScript with WebSocket (as a client), or do I have to use WebSocket in both server and client? how can i do that?
can I connect to this server using JavaScript with WebSocket (as a client),
Yes.
or do I have to use WebSocket in both server and client?
No.
Sockets are just implementing an access layer to the IP stack.
How these are implemented at client or server side is irrelevant for establishing and using a (TCP/)IP connection.
I really didn't know how to ask but, how would I setup a JavaScript SocketIO or Node socket server that would be able to accept messages from HTTP requests (Restful API)?Basically I have a Django back end, and want a SocketIO or Node server to run side by side, handling real time events fed to it through HTTP requests.
Is there anyway to send a HTTP request to the SocketIO or Node server that would the digest and send to broadcast to it's rooms? Or is this even realistic?
You can use Redis Pub/Sub along with your Django backend, Node server and and socket.io.
What you have to do is make your Django server listen to Http requests and publish real time events onto Redis. Also Start a Node.js server which would Subscribe to events published by your Django server on Redis. Then connect Socket.io to Node.js server to get events in real time on client side. Here is a tutorial
I have a simple server written in C. Its capable of receiving (and sending) messages via a specified socket. I'd like to use socket.io client to send messages to this server. I setup a simple html page and tried connecting via
var socket = io('http://my.server.ip:8080');
My server gets the connection but then socket.io gives this error repeatedly on the javascript console.
GET http://my.server.ip:8080/socket.io/?EIO=3&transport=polling&t=1431027762284-4 net::ERR_CONNECTION_RESET
I'm guessing my server should do a websocket 'handshake' to establish the connection. Is there a way to transmit a message in to a socket via JS with no handshake?
Please note my server does not use any standard, Its a rudimentary socket server that can receive and respond.
There are web socket server libraries you can use.
a plain socket does not work with web sockets.