slact / nchan

Fast, horizontally scalable, multiprocess pub/sub queuing server and proxy for HTTP, long-polling, Websockets and EventSource (SSE), powered by Nginx.
https://nchan.io/
Other
3.01k stars 293 forks source link

tag Nchan message read,websocket header post,messageid, transfer specified message #491

Closed Terrorist-1 closed 5 years ago

Terrorist-1 commented 6 years ago

Nchan is very well designed. I have planned to use it in actual products, but I have some questions to ask.

  1. How to mark if the message has been read? At present, only the message can be received. It seems that you can not actively send the message to the service unless puslish
  2. I use Nchan to build a websocket service, but I want to do a security check at heart Ping / pong. The scenario is that if I get a connection to a remote host address by grabbing a packet, I can connect to a remote server without any other security mechanism. If the heartbeat can be customized, it can expand a lot.
  3. I prefer Nchan to be an IM service. If I have multiple devices and the same account, then the latest message number on device A is 100, the latest message number on device B is 200, and the latest message number on the server is 300, that is, the device A only wants to receive messages between 100 and 300, and the device B only wants to receive messages between 200 and 300, instead of 100 to 300, is the current Nchan, and I think the corresponding solution is to set up a temporary channel for them, which is only available after the channel is launched. Client connection or disconnection reconnection, will bring the headers message, that is, the latest message number through the header, the server received the user online can intercept the header information, you can send the rest of the message to the temporary channel, and then destroy the channel, (channel number is limited) I have too many questions because I like it, and I want Nchan to do more and more important things, but I'm not sure if it has gone against the current design philosophy of Nchan pub / sub
slact commented 6 years ago
  1. How to mark if the message has been read?

There is no way to mark a message as read from within Nchan. You can, however, do this on the client-size. The message publishing response includes the field active subscribers, which indicates the number of subscribers present in the channel at time of publication, and therefore the number of subscribers that received the new message. There is no way to see if an already existing buffered messages has been received directly. You'll need to handle this on the client-side.

2

I don't understand the connection between websocket heartbeat pings and security checks. Can you rephrase this question?

3

Easiest way I can think of doing this is within the message body by encoding a message sequence number into the body.

The concern I have with doing "more things" is that Nchan already has a lot of complexity for the end user. The best way I've found to manage that is to stick pretty closely to the pub/sub model with a simple message buffer for each channel. For doing complex message buffer management, It may make sense to write a middle layer, or go with a custom pubsub server written in Node or something.

That said, I'm always open to feature requests -- I just turn down a lot more than i accept : )

Terrorist-1 commented 6 years ago

I saw your performance report, and the 6.5W subscription number was 0.4 seconds. What is the configuration of your nginx and Linux, can you send it out to have a look?

Because my test result here is that when the number of connections is 10,000, the message is received at the slowest rate of 3 seconds. I'm not sure where it's not configured correctly. I'm here Centos6.5 virtual machine Xeon (R) E5-2620 V2 @ 2.10GHz * 4 core 4G memory There is no network delay.

Terrorist-1 commented 6 years ago
  1. connect to count 30 thousand, and nchan_channel_id is the same value. It will take about 6 seconds to get the message.

  2. connection number to 30 thousand, their nchan_channel_id is different, the message gets very quickly, basically in milliseconds.

  3. is there any restriction on nchan_channel_id registration? Or nchan_channel_group restrictions