{"id":2430,"date":"2022-08-30T15:24:48","date_gmt":"2022-08-30T15:24:48","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/12\/node-js-socket-io-is-there-a-maximum-message-event-size-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:24:48","modified_gmt":"2022-08-30T15:24:48","slug":"node-js-socket-io-is-there-a-maximum-message-event-size-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/node-js-socket-io-is-there-a-maximum-message-event-size-collection-of-common-programming-errors\/","title":{"rendered":"node.js \/ socket.io is there a maximum message\/event size-Collection of common programming errors"},"content":{"rendered":"<p>the titel says it all &#8211; is there a maximum size for an event (or message) i want to send from the server to the client?<\/p>\n<p>i want to send a json string to the client and it looks something like this:<\/p>\n<pre><code>[{\"id\":\"4e25434f0f110ec101000005\",\"media\":\"4fb135d508e972664c5adf3.jpg\"},\n {\"id\":\"4e2545f30f110ec101000021\",\"media\":\"d09b745414e251695aa33e04.jpg\"},\n {\"id\":\"4e2554ce7bcfb24702000012\",\"media\":\"076eea872411e433b9.png\"},\n {\"id\":\"4e255bc4f34a41cb02000010\",\"media\":\"c2af3db4707db3ece.png\"}]\n<\/code><\/pre>\n<p>if the array would contain e.g. 200 items, would this crash?!<\/p>\n<ol>\n<li>\n<p>It would not crash, I accidentally send a array of 250 extreme large objects over Socket.IO and it handled it without any issues.<\/p>\n<p>You can just see it as sending a JSON object of 250 items over a http request, it could just take a while for the user to download it all.. Thats basically the only limitation you would be having.<\/p>\n<\/li>\n<li>\n<p>I dont think that will crash as node.js has an inbuilt nagle algorithm (if u havent disabled it) which buffers the data before sending it .<\/p>\n<p>http:\/\/www.nodejs.org\/docs\/v0.5.1\/api\/net.html#socket.setNoDelay<\/p>\n<p>Node.js alone can handle it easily for benchmarking purposes i have sent 800kb data in a chunk (random flush) . it took a lot of time to recieve on other side but was sent successfully.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-01-12 20:26:07. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>the titel says it all &#8211; is there a maximum size for an event (or message) i want to send from the server to the client? i want to send a json string to the client and it looks something like this: [{&#8220;id&#8221;:&#8221;4e25434f0f110ec101000005&#8243;,&#8221;media&#8221;:&#8221;4fb135d508e972664c5adf3.jpg&#8221;}, {&#8220;id&#8221;:&#8221;4e2545f30f110ec101000021&#8243;,&#8221;media&#8221;:&#8221;d09b745414e251695aa33e04.jpg&#8221;}, {&#8220;id&#8221;:&#8221;4e2554ce7bcfb24702000012&#8243;,&#8221;media&#8221;:&#8221;076eea872411e433b9.png&#8221;}, {&#8220;id&#8221;:&#8221;4e255bc4f34a41cb02000010&#8243;,&#8221;media&#8221;:&#8221;c2af3db4707db3ece.png&#8221;}] if the array would contain e.g. 200 items, would [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2430","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2430"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2430\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}