I have a self hosted SignalR hub that sends huge data sets in JSON format to the client. On average, I am sending close to 10MB worth of data. Is there a way that I can compress the JSON objects prior to it being sent to the client?
Streaming and compression are incompatible unless you did your own custom compression and decompression. You can gzip just fine if you're willing to only use longpolling since it requires the whole stream to be read before compressing. The problem is there's
no "whole stream" when you're streaming infinitely.
ethan.siew
0 Points
4 Posts
Self hosted SignalR hub compression
Feb 25, 2013 08:49 AM|LINK
Hi,
I have a self hosted SignalR hub that sends huge data sets in JSON format to the client. On average, I am sending close to 10MB worth of data. Is there a way that I can compress the JSON objects prior to it being sent to the client?
Thanks in advance for your advise.
Best Regards,
Ethan
Rion William...
All-Star
27138 Points
4504 Posts
Re: Self hosted SignalR hub compression
Feb 25, 2013 12:06 PM|LINK
This Stack Overflow is a discussion attempting to use gzip compression along with SignalR. It suggests using a custom HttpClient to handle decompressing the compressed messages after they come across. It may be worth looking into althought there are some SignalR experts around here that may be able to help out a bit more.
ethan.siew
0 Points
4 Posts
Re: Self hosted SignalR hub compression
Feb 26, 2013 12:51 AM|LINK
Thanks Rion for the response.
Took a look at the StackOverflow thread and it seems like people are not too optimistic about compression and data streaming.
Perhaps I can should the JSON before I send it over to SignalR ;_)
davidfowl
Contributor
2695 Points
609 Posts
Microsoft
Re: Self hosted SignalR hub compression
Feb 26, 2013 03:25 AM|LINK
Streaming and compression are incompatible unless you did your own custom compression and decompression. You can gzip just fine if you're willing to only use longpolling since it requires the whole stream to be read before compressing. The problem is there's no "whole stream" when you're streaming infinitely.
Senior SDE, ASP.NET Team, Microsoft
Rion William...
All-Star
27138 Points
4504 Posts
Re: Self hosted SignalR hub compression
Feb 26, 2013 03:41 AM|LINK
I would trust David's response to this issue (as he was the lead developer of SignalR). Just another one of the great things about these forums :)