From 9e282febfd09ad5c4f6c740975d35c37a275fea2 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Thu, 8 May 2014 11:13:08 +0200 Subject: relay: fix disconnection of client on empty websocket frames WeeChat disconnects any client when a frame with length 0 is recieved. --- src/plugins/relay/relay-client.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/relay/relay-client.c b/src/plugins/relay/relay-client.c index 6153ddfb3..63ae2ed80 100644 --- a/src/plugins/relay/relay-client.c +++ b/src/plugins/relay/relay-client.c @@ -488,7 +488,16 @@ relay_client_recv_cb (void *arg_client, int fd) (unsigned long long)num_read, (unsigned char *)decoded, &decoded_length); - if (!rc || (decoded_length == 0)) + if (decoded_length == 0) + { + /* When decoded length is 0, assume client sent a PONG frame. + * + * RFC 6455 Section 5.5.3 + * "A Pong frame MAY be sent unsolicited. This serves as a unidirectional heartbeat. A response to an unsolicited Pong frame is not expected." + */ + return WEECHAT_RC_OK; + } + if (!rc) { /* error when decoding frame: close connection */ weechat_printf_tags (NULL, "relay_client", -- cgit v1.2.3