On Fri, 16 Feb 2018 15:04:19 +0100, Sönke Ludwig wrote:

Am 30.01.2018 um 18:22 schrieb Paolo Invernizzi:

An exception is thrown in line 2367 while writing to the connection, in ddb master.

2357 void write(const(ubyte[]) bytes)
2358  {
2359            // Vibe:  "... If connected is false, writing to the connection will trigger an exception ..."
2360            if (!tcpConnection.connected)
2361            {
2362                // Vibe: " ... Note that close must always be called, even if the remote has already closed the
2363                //             connection. Failure to do so will result in resource and memory leakage.
2364                tcpConnection.close();
2365                connect();
2366            }
2367            tcpConnection.write(bytes);
2368       }

I think that the remote peer (the Postgres service) is disconnecting the vibe client


How many bytes are written in that call to write? Since write by
default tries to write all bytes, it may need to be broken up into
multiple packets, meaning that the connection reset could happen during
the call between any of those packets.

If vibe-core is used, a possible approach to avoid that would be to use
IOMode.once and to put a while (bytes.length) loop around the
function body (shrinking the slice according to the return value of

However, since this is talking to a Postgres server that would of course
just corrupt the communication protocol. So I'd probably just wrap the
code that sends a single message in a try/catch, attempt to
re-connect in the catch, and then resend the whole message instead.
After all, there will always be cases where writing can unexpectedly
fail. Of course, there would still be a .connected check in the
beginning to avoid spurious errors if the connection was closed cleanly.

Talking about protocol, is there maybe a possibility that the Postgres
server forcably closes the connection, because the first part of the
message is in some way invalid?

Thanks for your reply Sönke,

I've finally find out that the exceptions is related to network errors that are occurring in the connection between two docker containers in a docker swarm.
It seems that there's a lot of people suffering from unreliable network in the current implementation...

I've just given up in using a swarm until the thing is fixed on docker-side, and everything is fine again.

Anyway, I've tried also to reconnect in the catch, but the following call to write simply hangs vibe-core.