I want to send group messages but when I am sending it first time its working fine but after when I received it, it occurs duplication of the messages. Number of duplication of sending messages is equal to number of received messages.
I tried to use Message Connection for sending message.
I have faced a similar issue.
The best solution for such is to give your messages an id value before sending them. You could encode in JSON.
Then check for the existence of the message id (if it doesnt exist) before storing/rendering the message.
Related
I want to create a Telegram bot and use it, inside a group, as a bridge to get user messages and information, then send messages through the bot with a fake name.
So the Problem is: Bot receives the message after it's broadcasted to everyone and I should get the message and delete it, then do my stuff but this can reveal the user's identity.
I want to get the message before it's broadcasted to anyone and:
Prevent the message from broadcasting.
Bridge message through the bot and send the same message as the fake user created in my server.
Is there any other solution to use out there? except inline mode?
Intro
We're developing a system to support multiple real-time messages (chat) and updates (activity notifications).
That is, user A can receive via Web Socket messages for :
receiving new chat messages
receiving updates for some activity, for example if someone like their photo.
and more.
We use one single WebSocket connection to send all these different messages to the client.
However, we also support multiple applications/clients to be open by the user at the same time.
(i.e - user A connect on their web browser, and also from their mobile app, at the same time).
Architecture
We have a "Hub" that stores a map of UserId to a list of active websocket sessions.
(user:123 -> listOf(session#1, session#2))
Each client, once websocket connection is established, has its own Consumer which subscribes to a pulsar topic "userId" (e.g - user:123 topic).
If user A connected on both mobile and web, each client has its own Consumer to topic user:A.
When user A sends a new message from session #1 to user B, the flow is :
user makes a REST POST request to send a message.
service stores a new message to DB.
service sends a Pulsar message to topic user:B and user:A.
return 200 status code + created Message response.
Problem
If user A has two sessions open (two clients/websockets), and they send a message from session #1, how can we make sure only session #2 gets the message ?
Since user A has already received the 200 response with the created message in session #1, there's no need to send the message to him again by sending a message to his Consumer.
I'm not sure if it's a Pulsar configuration, or perhaps our architecture is wrong.
how can we make sure only session #2 gets the message ?
I'm going to address this at the app level.
Prepend a unique nonce (e.g. a guid) to each message sent.
Maintain a short list of recently sent nonces,
aging them out so we never have more than, say, half a dozen.
Upon receiving a message,
check to see if we sent it.
That is, check to see if its nonce is in the list.
If so, silently discard it.
Equivalently, name each connection.
You could roll a guid just once when a new websocket is opened.
Or you could incorporate some of the websocket's addressing
bits into the name.
Prepend the connection name to each outbound message.
Discard any received message which has "sender" of "self".
With this de-dup'ing approach
there's still some wasted network bandwidth.
We can quibble about it if you wish.
When the K-th websocket is created,
we could create K topics,
each excluding a different endpoint.
Sounds like more work than it's worth!
I've this case when I have to send message to collection of devices using their tokens but I want to put user name or some data that related to the user (variable) in the body of the notification like
Dear %name% you got degree %degree%
The problem now that I've to send a notification request to each user that's mean if I have 100k user => 100k request
Now I'm using Redis queue for the sending but I want to know if there is better way to do that
Not sure how it is used together with Redis, but at last look into it:
Make sure that you send your messages in batches. Build lists of 500 individual messages and send those using e.g. sendAll() from the FCM admin SDK.
Stating the obvious: 100k messages will be 200 requests.
https://firebase.google.com/docs/cloud-messaging/send-message#send-a-batch-of-messages
I am evaluating MessageBird service. I got a Virtual Mobile Number. I am able to send message to dummy numbers (until i get approval for sending messages to real USA number)
Unknown: My problem is about reading the messages received by a VMN.
Details: If I as a VMN owner send a message to consumer e.g. +1(111)111-1111 and i am interested in reading the response from the consumer, how to do get it?
MessageBird documentation expects me to know the ID for response message object (or my understanding is wrong). The documentation is good but i don't see a way to programmatically achieve it. Any suggestions How to achieve it?
Thanks in advance!
Messagebird have a feature of forward incoming sms data through webhook(get or post method). if you set an url then Messagebird will forward every incoming sms to you(or your server). You can easily read get/post response.
Normally I watch logs using tail -f /the/error.log, but I normally only act upon them when I hear people complain. I know you can send them to an email address, but email simply sucks. So I rather want the error logs of my server to be sent to a dedicated slack channel.
My question is: how can I watch additions to the error log and catch those additions in a variable so I can send them as json to the slack webhook? I also wonder, what if the error logs is more than one line? I don't want a 20-line error to be sent as 20 separate messages.
All tips are welcome!