armzilla / amazon-echo-ha-bridge

emulates philips hue api to other home automation gateways
Apache License 2.0
721 stars 168 forks source link

Version 0.4.0 attempts to bind to port 8081 in addition to specified port #85

Open screed01 opened 7 years ago

screed01 commented 7 years ago

NOTE: This issue does not exist with amazon-echo-bridge-0.2.1.jar.

I have OpenHab up and running and listening on port 8081. When I attempt to run the bridge on port 8082 (and have tried 8091 with no luck either), it fails to start. Here is my command:

java -jar amazon-echo-bridge-0.4.0.jar –upnp.config.address=192.168.168.5 –server.port=8082

The log shows the bridge attempting to bind to three ports: 2016-10-23 12:24:29.990 INFO 5828 — [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8082 (http) 8081 (http) 8082 (http)

And it fails trying to bind to the already used 8081 port: 2016-10-23 12:24:42.660 ERROR 5828 — [ main] o.a.coyote.http11.Http11NioProtocol : Failed to initialize end point associated with ProtocolHandler [“http-nio-8081”]

java.net.BindException: Address already in use: bind

jlekhter commented 7 years ago

Yeah, this version opens 3 ports by default starting with the value of --emulator.portbase+1. So if you set the value of emulator.portbase to 8082, you should see that it starts on 8082, then opens up two more ports on 8083 and 8084. If you set portbase, you should be fine.

The code should have probably defaulted portbase to server.port since in the current setting, if you change server.port to 8082 and dont modify portbase, tomcat tries to start on 8082, 8081, 8082 which causes the problem.