How to send spring-graphql client subscription ping messages - spring

I'm using the spring framework's spring-graphql library to create a graphql client, as per the docs. When connecting to the server using a websocket for subscriptions, everything works fine for 5 minutes but then the websocket times out and disconnects. It turns out the server requires the client to send a ping message to keep the websocket alive. This is a graphql ping message as specified in the graphql-ws protocol
I've checked in the docs and had a dig around in the code but can't see any way to send this ping message via the spring graphql client. Apollo client has similar functionality to what I'm after via a "keepalive" option in the graplq-ws ClientOptions. Is there any equivalent I can use via spring or alternative way to solve this?

I couldn't find any way to do this so raised an issue on github, and subsequently a PR with some changes to add basic support for sending pings.
See https://github.com/spring-projects/spring-graphql/pull/608
and https://github.com/spring-projects/spring-graphql/issues/605

Related

NestJS 8 Socket.io 4 have socket on the server side but not being reached

NestJS 8, socket.io 4
Client user has a socket being able to receive data from the server. Not sending.
Refresh browser, the socket ID changed. Socket on the client receive 'connect' event! Yet. On server side, no logging at all. Which kind of explained point 1.
After reboot nest, problem is gone. But it comes back eventually.
My current troubleshooting direction is
Was the connection on the client dead already and it's still trying somehow to update the socket?
Browser does some caching, service worker?
I hope someone can enlighten. This happens after upgrade to socket.io 4 from 2.
It's my own stupidity.
My tenant who own the namespace. In order to reach him, I create his namespace and send message to it no matter he's online or offline.
This works fine in socket.io 2. I don't know why.
What I should do, is to check whether or not, the namespace exists or not first.
That's why the issue that I have is that the server somehow seems able to pipe message to the namespace, yet the tenant cannot send the message to the server because the tenant was not initialized properly in the nest gateway.

Push data from websocket server to client

Websockets are hailed as a bi-directional process. However, whilst there are hundreds of websocket code examples on the web, they all require a request from the client(browser) to the server to get the data (like an echo server or chat).
So far, I have not found any code which will send new data (originating at the server end) to the client via an open websocket. Ideally, I would like to use a node.js server but I'm open to alternatives. Any ideas?

Oryx CycloneTCP WebSocket Support for HTTP Server

I've started to evaluate Oryx Embedded CycloneTCP library, and able to run HTTP server / DHCP client with CubeMX config tools and STM32CubeIDE for custom STM32H7 board.
However, I did not get how to configure WebSocket support for HTTP Server. So I need some help / sample / demo code for it.
Its an a bit older question, but nonetheless...
https://gricad-gitlab.univ-grenoble-alpes.fr/Projets-INFO4/20-21/05/STM32F7_CycloneServer
shows how to implement a simple websocket->CAN Bus gateway.
Take a look at CycloneServer/Core/Src/main.c
In httpServerRequestCallback() the http connection gets upgraded to a websocket connection.
Received frames are processed in a seperate task (clientTask()).
sendCANBusToClient() shows how to send messages to connected websockets.

ActiveMQ - Stomp over websockets - Same Origin Policy

I have a process that runs in California that wants to talk to a process in New York, using Stomp over Websockets.
Also note that my process is not a web app, but I implemented a stomp over websocket client in C++, in order to connect things up to my backend. Maybe this was or wasn't a good idea. So, I want my client to talk to the server and subscribe, where their client pushed messages.
I was implementing my own server when I saw that ApacheMQ supported Stomp over Websockets. So, I started reading the docs.
It says with the last line under 'configuration' at
http://activemq.apache.org/websockets :
One thing worth noting is that web sockets (just as Ajax) implements ? > the same origin policy, so you can access only brokers running on the > same host as the web application running the client.
it says it again in several related searches such as http://sensatic.net/activemq/activemq-54-stomp-over-web-sockets.html
Is this a limitation of the server or the web client?
With that limitation, if I understand right, the server is not going to accept websocket connections from a client, of any kind, that is not on the same machine?
I am not sure I see the point of that...
If that is indeed its meaning, then how do I get around it in order to implement my scenario?
I've not found that bit of documentation you are referring to but from what I know of the STOMP implementation on the broker this seems incorrect. There shouldn't be any limit to the transport connector accepting connect requests from an outside host by default and I don't think the browser treats the websocket requests the same as it does other things like an Ajax case in terms of the same origin policy.
This probably a case that is best checked by actually trying it to see if it works, I've connected just fine from outside the same host using AMQP over websockets on ActiveMQ so I'd guess the STOMP stack should also work fine.

Is it possible to maintain multiple clients in NanoHttpd?

I am trying to build a simple server/client application where the NanoHttpd server communicates with the client using WebSockets.
The server replies back with the same text that the client sent.
Is it possible to broacast messages to all the clients connected?
Any links about Nanohttpd with multiple-clients connected would be helpful.
https://github.com/PathikDevani/NanoHttpd-Demo
check my github project. here some example for multi user handle on websocket.
-------link is broken now

Resources