Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.io.IOException: Socket operation on non-socket #10941

Open
ZZerog opened this issue Nov 29, 2023 · 4 comments
Open

java.io.IOException: Socket operation on non-socket #10941

ZZerog opened this issue Nov 29, 2023 · 4 comments
Labels
Bug For general bugs on Jetty side

Comments

@ZZerog
Copy link

ZZerog commented Nov 29, 2023

Jetty version(s)
12.0.0 or 12.0.3

Jetty Environment
core

Java version/vendor
openjdk version "17.0.8" 2023-07-18

OS type/version
Linux raspberrypi 6.1.0-rpi4-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.54-1+rpt2 (2023-10-05) aarch64 GNU/Linux
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm

Description

Simple embedded Jetty server work really bad and after short time is a port closed.
All seem be fine, until call curl http://localhost/global/info/.
Then errors appear in the log.


  server = new Server(new InetSocketAddress("127.0.0.1", PORT));

  /*
  //different settings, same behavior
  ServerConnector serverConnector = new ServerConnector(server);
  serverConnector.setPort(PORT);
  serverConnector.setReuseAddress(true);
  serverConnector.setReusePort(true);
  server.addConnector(serverConnector);
  */
  
  server.addEventListener(new StatusEventListener());
  server.setStopAtShutdown(true);
  server.setRequestLog(new CustomRequestLog(new Slf4jRequestLogWriter(), CustomRequestLog.NCSA_FORMAT));
  
  ContextHandlerCollection contextCollection = new ContextHandlerCollection();

  ResourceHandler staticContext = new ResourceHandler();
  staticContext.setBaseResource(ResourceFactory.of(staticContext).newResource(staticDirectory.getAbsolutePath()));
  staticContext.setDirAllowed(true);
  staticContext.setAcceptRanges(false);
  contextCollection.addHandler(new ContextHandler(staticContext, "/static"));

  contextCollection.addHandler(new ContextHandler(new InfoHandler(moduleManager),URL_PREFIX+"/global/info"));

  server.setHandler(contextCollection);
  server.start();

The StatusEventListener just show starting and started event - no fail.
After logging was actived i see exception in the log.

EDIT: After some testing seems that static context (ResourceHandler) is a problem.


WARN   AbstractConnector: Accept Failure: java.io.IOException: Socket operation on non-socket
	at java.base/sun.nio.ch.Net.accept(Native Method)
	at java.base/sun.nio.ch.ServerSocketChannelImpl.implAccept(ServerSocketChannelImpl.java:425)
	at java.base/sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:391)
	at org.eclipse.jetty.server.ServerConnector.accept(ServerConnector.java:397)
	at org.eclipse.jetty.server.AbstractConnector$Acceptor.run(AbstractConnector.java:693)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:971)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1196)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1151)
	at java.base/java.lang.Thread.run(Thread.java:833)

and/or

WARN   AbstractConnector: Accept Failure: java.io.IOException: Invalid argument
	at java.base/sun.nio.ch.Net.accept(Native Method)
	at java.base/sun.nio.ch.ServerSocketChannelImpl.implAccept(ServerSocketChannelImpl.java:425)
	at java.base/sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:391)
	at org.eclipse.jetty.server.ServerConnector.accept(ServerConnector.java:397)
	at org.eclipse.jetty.server.AbstractConnector$Acceptor.run(AbstractConnector.java:693)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:971)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1196)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1151)
	at java.base/java.lang.Thread.run(Thread.java:833)

What I do wrong?
thx

@ZZerog ZZerog added the Bug For general bugs on Jetty side label Nov 29, 2023
@sbordet
Copy link
Contributor

sbordet commented Nov 29, 2023

I think this is more either a JVM bug or some incompatibility with the RBPi.

What exact Java vendor are you using?
I would try different ones and see if there is a difference.
I would not use whatever comes with Debian.
Install a suitable version from e.g. https://adoptium.net/

@ZZerog
Copy link
Author

ZZerog commented Dec 1, 2023

Yes. It looks like JVM bug. Now I am testing adoptium jvm and the behavior is correct!

I do not know exact Java vendor .. old JVM was installed through APT.

Thanks

@sbordet
Copy link
Contributor

sbordet commented Dec 1, 2023

Glad it's solved for you, closing the issue.

@sbordet sbordet closed this as completed Dec 1, 2023
@ZZerog
Copy link
Author

ZZerog commented Dec 1, 2023

Sorry, but while a time the error is back.

I tried JDK 21 and 17.
I will try isolate jetty from my other code and do more test.

@joakime joakime reopened this Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

3 participants