Fork me on GitHub
#pedestal
<
2020-09-19
>
Diego18:09:59

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?

isak18:09:48

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.

isak18:09:54

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

isak18:09:06

(This was in .NET though, not pedestal)

Diego01:09:04

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)

isak14:09:52

Ok. https://www.eclipse.org/lists/jetty-users/msg04961.htmlre you using Jetty? I think the relevant settings are more likely to be there. For example: https://stackoverflow.com/a/22871227

Diego19:09:33

yeah, thanks again!