jrief / django-websocket-redis

Websockets for Django applications using Redis as message queue
http://django-websocket-redis.awesto.com/
MIT License
895 stars 221 forks source link

ws4redis slices messages #276

Closed nrgx closed 5 years ago

nrgx commented 5 years ago

In ws4redis.js there is a function that sends messages to websockets. But, it only sends messages that are before colon or it slices very large message into small. For example if I write "test, message" it will only send "test" by websocket, but via axios.post I get whole message, also if I'd send "q, message" I'll get only "q". Or if I'll send "lorem" text it will also trim for several characters and the same axios posts whole message.

nrgx commented 5 years ago

The problem was that I sent username and message as array. ws4redis sent this to redis, so I got such messages: 127.0.0.1:6379> GET chat:broadcast:test "alibek,q,qq" Well redis sees user ("alibek") and message ("q") are separated by a colon, but there is also third item ("qq"). So redis just doesn't do anything to it.

Solution

Use JSON.stringufy at sendMessage() and JSON.parse at receiveMessage().

Всем спасибо, все свободны.