How to check Pusher Channel is available? - pusher

I am using Pusher for channels and live streaming.
I create channel. Can I check status of a particular channel that if it is created or is streaming or not.
Thanks.

There's no action to create a channel; you can publish data to a channel and subscribe to one. When a a channel is subscribed to it is occupied and when there are no subscribers it is vacant.
You can check whether a channel has any subscribers (is occupied) by querying the HTTP API for channel information:
https://pusher.com/docs/server_api_guide/interact_rest_api#channel-information
Some libraries have helper functions for this e.g. the PHP library:
https://github.com/pusher/pusher-http-php#get-information-about-a-channel

Related

How can I find out that my redis channel does not currently have the publisher?

How can I find out that my redis channel does not currently have the publisher?
Redis pub/sub is fire and forget. once you publish the message no guarantee that it will deliver to the subscriber if subscriber not available at that time. Redis pub/sub will only guarantee that order of messages. I would suggest use Redis Stream. you can use consumer group in Redis stream to have multiple consumers. It will guarantee the message delivery with acknowledgement option.
Please go through
Use PUBSUB CHANNELS [channelname] to find the number of subscribers for the specified channels/publisher.

Request response pattern with mosca MQTT

Is there any way to implement request-response pattern with mosca MQTT to "check reply from the client and re publish if i dont receive expected reply within expected time".
I believe this is possible in Mqtt 5, but as of now, I have to use Mosca broker with QoS 1(which support until Mqtt 3.1.1)
I am looking for a Node js workaround to achieve this.
As per my comment you can implement a request-response pattern with any MQTT broker but, prior to v5, you need to implement this yourself (either have a single reply-to topic and a message ID, or include a specific reply-to topic within each message).
Because MQTT 3.11 itself does not provide this functionality directly and there is no standard format for the MQTT payload (just some bytes!) its not possible to come up with a generic implementation (a unique id of some kind is needed within the request). This is resolved in MQTT v5 through the ability to include properties including Response Topic and Correlation Data. For earlier versions you are stuck with adding some extra information into the payload (using whatever encoding mechanism you choose).
There are a few Stack Overflow questions that might provide some insight:
MQTT topic names for request/response
RPC style request with MQTT
Other articles:
Eclipse Kura
Stock Explorer
IoT Application Development Using Request-Response Pattern with MQTT (Academic article - purchase needed to read whole thing).
Amazon device shadow MQTT topics (e.g. send message to $aws/things/thingName/shadow/get and AWS IoT responds on /get/accepted or /get/rejected).
Here are a few node packages (note: these have not been updated for some time and I have not reviewed the code):
replyer
resmetry
Even with MQTT v5 you would need to implement the idle timeout bit yourself. If you are using QOS 1/2 then the broker will take care of resending the message (until it receives a PUBACK/PUBCOMP) so resending the message may be counterproductive (lots of identical messages queued up while the comms link is down)
The summary of the workflow i have done
Adding "Correlation Id" for each message
The expected reply is stored in Redis as the Request Payload(Request with the
Correlation Id as a key) to compare response from the client.
The entry will be removed from Redis if the expected message is
equivalent to the expected response topic and payload.
Time out uses node cron jobs for each response from the client to
Server.

How to get online users using pusher

I am developing chat application using Pusher. As of now whenever user logs in into his account, he is subscribed to a channel like below:
`var channel = pusher.subscribe('<?='myChannel'.$_SESSION['USERID']?>');`
I would like to update the status in chat list for online/offline so that other users can get to know whether user is online or not. How can I do that?
Normally you would use presence channels for this. These channels have special events which are broadcast to all other subscribers when a members subscribes/unsubscribes from the channel.
It looks like you have a channel per user, so this wouldn't work by simply converting the existing channels to presence channels. Instead you could have a special presence channel in addition to the per-user channels that all users subscribe to. Here you can bind to presence events and update the members list.

Send my message only to subscribed server and not to my other servers

How do I send my message that is published to a Redis channel only to subscribed server (which is connected to the subscriber) and not to my other servers (where the required subscriber isn't connected).
I'm using Socket.IO and Redis server.
Have you read the documentation?
not programmed to send their messages to specific receivers (subscribers). Rather, published messages are characterized into channels, without knowledge of what (if any) subscribers there may be
I other words, you cannot target a specific subscriber.
Depending on what you are trying to achieve, you can consider using multiple channels, with each consumer using its own.

PubNub Chat: Which sorting channels based on which is most recently updated

I am using PubNub to create a Chat. Each chatroom is a PubNub channel. The challenge now is: how do I sort my channels such that channels with most recent posts should be on top.
I can think on 2 possibilities:
Server will listen to all channels, when a message is received, it logs it. So a chatroom model might look like {id, name, users, lastUpdate}
Everytime message is posted, app will also call server to pass in that message
Both methods doesnt seem to correct? Is there a better way? The first will require the server to listen on all channels. The second will require server to handle a request for each message.
How about using timestamp?
Actually, PubNub offers Presence APIs that lets you monitor the state of each channel, with timestamp (which specified as 17-digit precision unix time).
http://www.pubnub.com/knowledge-base/discussion/276/presence

Resources