Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
UDP Client: Support writing large reports
Browse files Browse the repository at this point in the history
If a report is larger than 65536 it will be rejected by kernel and PHP engine and never sent. With this, we ensure that the packet is always sent and that it has proper signaling (MSG_EOR or MSG_EOF).

TLDR; Solves the following issue:

```PHP Warning:  socket_sendto(): unable to write to socket [90]: Message too long```
  • Loading branch information
dz0ny committed Oct 7, 2018
1 parent 6b4d2f0 commit 0338f50
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/Jaeger/UDPClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@ public function emitBatch(Batch $batch)
$client = new AgentClient(null, $protocol);

$client->emitBatch($batch);
$data = $buffer->getBuffer();

try {
socket_sendto(
$socket,
$data,
strlen($data),
0,
$this->host,
$this->port
);
while ($buffer->available()) {
$data = $buffer->read(65536); // max size of DGRAM packet
socket_sendto(
$socket,
$data,
strlen($data),
( $buffer->available() ) ? MSG_EOR : MSG_EOF,
$this->host,
$this->port
);
}
} finally {
socket_close($socket);
}
Expand Down

0 comments on commit 0338f50

Please sign in to comment.