SocketCluster / SocketCluster/socketcluster
Publish does not fail when there are no sockets subscribed to channel.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6.2k
- Forks
- 318
- PR merge metrics
- No merged PRs in 30d
Description
I am using the below code within worker.js to allow a back end PHP script to push messages to clients.
The err function never executes even when there are no sockets subscribed to the channel.
Is there some way to detect when there are no active subscriptions to a channel?
app.post('/push', (request, response) => {
const postBody = request.body;
console.log("Received push message for : " + postBody['channelid'] + " From : " + request.connection.remoteAddress);
var message = new Object();
message.type="alert";
message.data=postBody['messagedata'];
scServer.exchange.publish(postBody['channelid'],message, function (err) {
if (err) {
// Failed to publish event, retry or let the user know and keep going?
console.log("Push Failed");
response.sendStatus(500)
response.end();
} else {
// Event was published successfully
console.log("Push Sent to Channel");
response.sendStatus(200)
response.end();
}
});
});
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with worker.js and the /push handler's scServer.exchange.publish call; read the publish callback contract and channel subscription behavior. Reproduce the request with no subscribed sockets and determine whether the requested detection is supported. Done means the behavior is clarified or a documented, tested way to detect inactive subscriptions is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100