diff --git a/src/jaegertracing/utils/HTTPTransporter.h b/src/jaegertracing/utils/HTTPTransporter.h index 5340d242..a7a3f3f5 100644 --- a/src/jaegertracing/utils/HTTPTransporter.h +++ b/src/jaegertracing/utils/HTTPTransporter.h @@ -63,9 +63,17 @@ class HTTPTransporter : public Transport { const auto numWritten = ::send(_socket.handle(), reinterpret_cast(data), sizeof(uint8_t) * size, 0); if (static_cast(numWritten) != size) { - std::ostringstream oss; - oss << "Failed to write message, numWritten=" << numWritten << ", size=" << size; - throw std::system_error(errno, std::system_category(), oss.str()); + // Reconnect and try again + _socket.close(); + _socket.open(AF_INET, SOCK_STREAM); + _socket.connect(_serverAddr); + + const auto numWrittenBis = ::send(_socket.handle(), reinterpret_cast(data), sizeof(uint8_t) * size, 0); + if (static_cast(numWrittenBis) != size) { + std::ostringstream oss; + oss << "Failed to write message, numWritten=" << numWrittenBis << ", size=" << size; + throw std::system_error(errno, std::system_category(), oss.str()); + } } // Waits for response. Check that the server acknowledged