Fork me on GitHub

Hello everyone, I am working with websockets and am wondering if there is some kind of default ping/pong for keeping the connections alive? I have looked around and haven't been able to find anything on this respect. If there is nothing, what is the or a recommended approach?


There is something built in, but sometimes they still get closed by code outside your app (on the firewall, for example). One approach I've seen people take is to just send a {"type": "ka"} (ka = keepalive) message every 30 seconds, if no other message has been sent. Hasura does this for GraphQL subscriptions, for example.


For another project I tried sending ping/pong messages (a special message type in the websocket spec), but it didn't change anything, and those messages don't appear as frames in the browser tooling


(This was in .NET though, not pedestal)


Thanks @U08JKUHA9, for the mean time I cooked my own ping/pong and it seems to work, though I still wonder if there might be something in pedestal that already does this (although I did look into some parts of the codebase)


Ok. you using Jetty? I think the relevant settings are more likely to be there. For example:


yeah, thanks again!