Skip to content

Ws crlf keep alive enhancement #6

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
### NEXT RELEASE

* TS: fix socket/transport types (#790).
* Transport: Handle keep alive request from server (#791).


### 3.10.0
Expand Down
20 changes: 19 additions & 1 deletion lib/Transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,25 @@ module.exports = class Transport

_onData(data)
{
// CRLF Keep Alive response from server. Ignore it.
// CRLF Keep Alive request from server, reply.
if (data === '\r\n\r\n')
{
logger.debug('received message with double-CRLF Keep Alive request');

try
{
// Reply with single CRLF.
this.socket.send('\r\n');
}
catch (error)
{
logger.warn(`error sending Keep Alive response: ${error}`);
}

return;
}

// CRLF Keep Alive response from server, ignore it.
if (data === '\r\n')
{
logger.debug('received message with CRLF Keep Alive response');
Expand Down