offbynull/portmapper

No buffer space available (maximum connections reached?)

Closed this issue · 5 comments

Hi,
I'm getting this exception on two different computers while trying to test both uPNP and NAT-PMP.

[Network IO] ERROR com.offbynull.portmapper.gateways.network.NetworkRunnable - 2 Exception encountered
java.net.SocketException: No buffer space available (maximum connections reached?): no further information
    at sun.nio.ch.DatagramChannelImpl.send0(Native Method)
    at sun.nio.ch.DatagramChannelImpl.sendFromNativeBuffer(DatagramChannelImpl.java:532)
    at sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:509)
    at sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:473)
    at com.offbynull.portmapper.gateways.network.NetworkRunnable.handleSelectForUdpChannel(NetworkRunnable.java:256)
    at com.offbynull.portmapper.gateways.network.NetworkRunnable.run(NetworkRunnable.java:113)
    at java.lang.Thread.run(Thread.java:745)

Hey.

This error is benign. During the PCP/NAT-PMP discovery process, the library
runs a couple of processes to find gateway ips on your machine. It scrapes
every ipv4 and ipv6 address in the output of those processes and checks to
see it it responds to NAT-PMP/PCP messages.

Some of those ips aren't valid (e.g. 0.0.0.0), so when you try to send a
udp packet to them you'll get that exception. The error is slightly
different for mac/linux/android, but they all get an exception.

The exception doesn't hinder the operation of the library in any way.

I'll see if I can come up with some good logic tonight/tomorrow to filter
out invalid ips before they get accessed.

On Jul 19, 2016 7:14 AM, "lpetrovic05" notifications@github.com wrote:

Hi,
I'm getting this exception on two different computers while trying to test
both uPNP and NAT-PMP.

[Network IO] ERROR com.offbynull.portmapper.gateways.network.NetworkRunnable - 2 Exception encountered
java.net.SocketException: No buffer space available (maximum connections reached?): no further information
at sun.nio.ch.DatagramChannelImpl.send0(Native Method)
at sun.nio.ch.DatagramChannelImpl.sendFromNativeBuffer(DatagramChannelImpl.java:532)
at sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:509)
at sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:473)
at com.offbynull.portmapper.gateways.network.NetworkRunnable.handleSelectForUdpChannel(NetworkRunnable.java:256)
at com.offbynull.portmapper.gateways.network.NetworkRunnable.run(NetworkRunnable.java:113)
at java.lang.Thread.run(Thread.java:745)


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#27, or mute the thread
https://github.com/notifications/unsubscribe-auth/AGD4IomlzUQ-2oNAdbKX97vJNzMGAH0Uks5qXNvGgaJpZM4JPxT-
.

It would be great if these exceptions would be logged as debug at least, because they are not necessarily errors

Sorry for the delay. I had some things that needed my attention.

I'll get this sorted out by tomorrow end of day.

I just release 2.0.4. It should up on maven central soon.

I tried to reduce the amount of error logging by filtering out some IPs and changing the log level of those exceptions to debug. But, it's impossible to get rid of these exceptions entirely. The library tries to scan all network interfaces for port mappers. Certain network interfaces will throw exceptions when you try to bind/send/recv/connect/etc... on them.

I don't think there's a reliable way to check for this before hand.

In addition to these logging tweaks, there are a bunch of other bug fixes. See changelog in readme for more details.

Closing ticket.