Message lost on 2 separate connections to same URL
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- php
- Domain
- networking
Research direction
Start with the publish method and its ratchet\client\connect calls, then reproduce the two back-to-back publishes shown in the issue. Trace why the first message is ignored when separate connections use the same URL, and verify the behavior with both messages sent independently. Done means the cause is identified and both messages are reliably delivered, or the limitation is documented.
Written by the indexing model from the issue text.
Description
Using ratchet/pawl v0.4.1 and PHP 7.4
Implemented pub/sub client in PHP...
public function publish(string $user, string $group, string $message)
{
$hubUrl = $this->getHubUrl();
$accessToken = $this->getAccessToken($user);
$url = $hubUrl.'?access_token='.$accessToken;
$this->user = $user;
$this->group = $group;
$this->message = $message;
\ratchet\client\connect($url,['json.webpubsub.azure.v1'])->then(function($conn) {
$sendMessage = [
'type' => 'sendToGroup',
'group' => $this->group,
'data' => [
'message' => $this->message
]
];
$sendMessageText = json_encode($sendMessage);
$joingroup = [
"type" => "joinGroup",
"group" => $this->group
];
$joingroupText = json_encode($joingroup);
$conn->send($joingroupText);
$conn->send($sendMessageText);
$conn->close();
}, function ($e) {
error_log("Could not connect: {$e->getMessage()}\n");
});
}
This works great. However, if I send back-to-back messages, e.g.
$pubSubService->publish('server','activity-queue',json_encode($queueEntry));
$pubSubService->publish('server','agent-table',json_encode($agent));
The first message is always lost. I've fixed this by queuing up the messages to the same URL and sending them together on the same connection. A much better design, I admit.
At the same time, this should work. Why do back-to-back messages on separate connections to the same URL fail? It took me quite a while to find this. There are no error messages. The first messages is simply ignored.
- Dominant language
- PHP
- Stars
- 616
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
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.
More from ratchetphp/Pawl
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
ratchetphp/Pawl#166 · 6 comments · 5 reactions ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ratchetphp/Pawl#165 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
ratchetphp/Pawl#163 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
ratchetphp/Pawl#157 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
ratchetphp/Pawl#156 ·
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getgrav/grav-plugin-api#45 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
RSS-Bridge/rss-bridge#5098 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
phingofficial/phing#2025 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
silverstripe/developer-docs#911 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100