{"action":"opened","issue":{"url":"https://api.github.com/repos/RobotWebTools/rosbridge_suite/issues/171","labels_url":"https://api.github.com/repos/RobotWebTools/rosbridge_suite/issues/171/labels{/name}","comments_url":"https://api.github.com/repos/RobotWebTools/rosbridge_suite/issues/171/comments","events_url":"https://api.github.com/repos/RobotWebTools/rosbridge_suite/issues/171/events","html_url":"https://github.com/RobotWebTools/rosbridge_suite/issues/171","id":57781727,"number":171,"title":"Websocket handler and Nagle's algorithm","user":{"login":"smamessier","id":1063314,"avatar_url":"https://avatars.githubusercontent.com/u/1063314?v=3","gravatar_id":"","url":"https://api.github.com/users/smamessier","html_url":"https://github.com/smamessier","followers_url":"https://api.github.com/users/smamessier/followers","following_url":"https://api.github.com/users/smamessier/following{/other_user}","gists_url":"https://api.github.com/users/smamessier/gists{/gist_id}","starred_url":"https://api.github.com/users/smamessier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smamessier/subscriptions","organizations_url":"https://api.github.com/users/smamessier/orgs","repos_url":"https://api.github.com/users/smamessier/repos","events_url":"https://api.github.com/users/smamessier/events{/privacy}","received_events_url":"https://api.github.com/users/smamessier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-16T09:31:11Z","updated_at":"2015-02-16T09:31:11Z","closed_at":null,"body":"Using Rosbridge Websocket and Roslibjs, I subscribe to a 60 Hz Ros message at a 15 ms throttle rate with 0 queue size, I end up receiving 6 messages at a time but every 100 ms.\r\nI took me some time but I tracked this lag down to Nagle's algorithm that gathers tcp messages together before sending when small and sent at a high frequency. \r\nThis way, low throttle rate (typically under 50 ms) are only respected in average and this is a huge problem when you want some decent head tracking for instance.\r\n \r\nUsing Tornado WebSocketHandler API, I tried tu use self.set_nodelay(True) which is supposed to deactive Nagle but without success. (Still the same message scheduling pattern)\r\n\r\nI only found a kludgy way of achieving 15 ms between each message by forcing Roslibjs to ping back the websocket server on each message reception (this forces Nagle's algorithm to flush). Idea come from this post \r\nhttp://stackoverflow.com/questions/13373519/websocket-tcp-packets-clumping-together/13406438#13406438\r\n"}}