Socket NIF and packet_size - seeing an emsgsize for large TCP messages when the inet_backend is set to socket

I am seeing an emsgsize for large TCP messages when the inet_backend is set to socket. I saw that there is a packet_size opt in the documentation and bumping that up to the appropriate size seems to have done the trick. In the OTP source I see that this defaults to 64MB. To test this, I sent 64MB over the socket, and the message is received successfully. I then sent 65MB, and saw that it fails with the emgsize error. This leads me to believe that adjusting packet_size is the correct approach.

This issue doesn’t happen when the inet backend is the default. This seems like it should be documented that the socket backend needs the packet_size option to be explicitly set if the expected data size is large, if this is the case.

2 Likes

This smells like a bug for the socket backend.
Do you use any other packet options, or the default raw packets (no packeting)?

Can you provide a small example?

2 Likes

I’ll try to come up with a small repro. Here are the opts:

Opts =
   [
      {inet_backend, socket}, % has to come first for some reason.
      inet,
      binary,
      {packet, 4},
      {active, false},
      {nodelay, true},
      {ip, loopback}
   ]

Now they include {packet_size, 104857600}.

1 Like