pedestal

2020-09-19T18:36:59.001800Z

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?

isak 2020-09-21T18:18:48.002200Z

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.

isak 2020-09-21T18:19:54.002400Z

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

isak 2020-09-21T18:20:06.002600Z

(This was in .NET though, not pedestal)

2020-09-22T01:36:04.002800Z

Thanks @isak, 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)

isak 2020-09-22T14:22:52.003100Z

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

2020-09-22T19:58:33.003400Z

yeah, thanks again!