Question

I am trying to run 2 Dropwizard Server applications on 2 different ports 8080 and 9000.The first application starts successfully but I keep getting the below exception when I try to run on port 9000. What I am not understanding is that why are 2 ports being used by the application and how do I enforce my application to use a different port number for the second port

INFO  [2014-03-22 17:17:28,031] org.eclipse.jetty.server.AbstractConnector: Started    
InstrumentedBlockingChannelConnector@0.0.0.0:9000 
WARN  [2014-03-22 17:17:28,033] org.eclipse.jetty.util.component.AbstractLifeCycle: FAILED   
SocketConnector@0.0.0.0:8081: java.net.BindException: Address already in use
! java.net.BindException: Address already in use
! at org.eclipse.jetty.server.bio.SocketConnector.newServerSocket(SocketConnector.java:96)    
~[jetty-server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.bio.SocketConnector.open(SocketConnector.java:85) ~[jetty-
server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:316) ~
[jetty-server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.bio.SocketConnector.doStart(SocketConnector.java:156) ~
[jetty-server-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) 
[jetty-util-8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.server.Server.doStart(Server.java:291) [jetty-server-
8.1.10.v20130312.jar:8.1.10.v20130312]
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) 
[jetty-util-8.1.10.v20130312.jar:8.1.10.v20130312]
! at com.yammer.dropwizard.cli.ServerCommand.run(ServerCommand.java:48) [dropwizard-core-
0.6.2.jar:na]
! at com.yammer.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:39) 
[dropwizard-core-0.6.2.jar:na]
! at com.yammer.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:58) 
[dropwizard-core-0.6.2.jar:na]
! at com.yammer.dropwizard.cli.Cli.run(Cli.java:53) [dropwizard-core-0.6.2.jar:na]
! at com.yammer.dropwizard.Service.run(Service.java:61) [dropwizard-core-0.6.2.jar:na]
! at com.paypal.demandgen.places.indexing.IndexingServer.main(IndexingServer.java:96)    
[classes/:na]
WARN  [2014-03-22 17:17:28,034] org.eclipse.jetty.util.component.AbstractLifeCycle: FAILED or
Était-ce utile?

La solution

Dropwizard actually serves up two sites: the main site, and an admin site on a different port. The admin section allows you to view metrics and healthchecks on your site.

In this instance, the problem is due to the Admin client, which by default runs on port 8081. So you need to also set -Ddw.http.adminPort=9001 (for instance)

Autres conseils

Use the below settings in yml file to run the server on different port ( some of the settings are general settings configured to improve the performance of the server )

server:
  applicationConnectors:
    - type: http
      port: 9179
      outputBufferSize: 32KiB
      idleTimeout: 30 seconds
      minBufferPoolSize: 64 bytes
      bufferPoolIncrement: 1KiB
      maxBufferPoolSize: 64KiB
      acceptorThreads: 1
      selectorThreads: 2
      acceptQueueSize: 1024
      reuseAddress: true
      soLingerTime: 600s
  adminConnectors:
    - type: http
      port: 9180

you can try one thing that you can check console and if your server is running already then in console you will see a red color button for terminate if that but is enable(clickable) then click on that and rerun your code this time eclipse will reinitialize the all instance of server and ports as well.

What worked for me was making these changes

server:
  applicationConnectors:
    - type: http
      port: 6666
    - type: https
      port: 6444
  adminConnectors:
    - type: http
      port: 6667
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top