question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add getPort() or similar to ServerImpl

See original GitHub issue

I noticed that there doesn’t seem to be a way to programatically retrieve a way to get the port a ServerImpl is listening on. Could we add a method that provides this information?

I would argue it’s useful for when one wants to bind to port 0 i.e.

ServerImpl server = NettyServerBuilder.build();
server.start()

System.out.println("Server listening on port " + server.getPort());

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stepanchegcommented, Feb 14, 2016

Any news on the issue? It is super-important for unit-tests. When running unit-tests you need to bind on random port, because otherwize tests occasionally fail giving headaches to developers.

AFAIU, this feature can be implemented easily, it just needs to be decided what API should look like.

I’d prefer ServerImpl to have getPort() function that returns 0 if server is not listening on IP.

0reactions
carl-mastrangelocommented, Apr 13, 2016

I am marking this as closed, even though there may be more followup work for exposing the SocketAddress.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.net.Socket.getPort java code examples - Tabnine
SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket( raw, raw.getInetAddress().getHostAddress(), raw.getPort(), true);
Read more >
Inject caller ip address and port not working in Java Jersey ...
getRequestUri().getPort(); ... } The type for the injected object was wrong, I used com.sun.jersey.api.core.HttpContext; instead.
Read more >
io.grpc.internal.ServerImpl Maven / Gradle / Ivy - Download JAR files
ServerImpl maven / gradle build tool code. ... private boolean terminated; /** Service encapsulating something similar to an accept() socket.
Read more >
Java Map Examples, org.gudy.azureus2.core3.tracker.server.impl ...
Namespace/Package Name: org.gudy.azureus2.core3.tracker.server.impl ... getTime() > CONNECTION_ID_LIFETIME) { return (false); } } boolean ok = data.
Read more >
org.subethamail.smtp.server.SMTPServer Java Examples
You can vote up the ones you like or vote down the ones you don't like, ... @Override public void startup() { serverImpl...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found