javarestpostmangrizzly

REST call to ip does not work, but localhost works


i have a implemented a http server (glassfish grizzly) in java.

If i submit a REST GET to localhost:3000/api/... i receive my response as expected.

If i sumbit that REST GET with my ip (192.168.0.100:3000/api...) i'm getting a "no reponse error".

Exactly the same behaviour when i start that java application on a different computer (192.168.0.200) in the same network. A GET request to 192.168.0.100:3000/api... also leads to the "no response error".

Am i missing something?


Solution

  • Configure GlassFish to use the correct HTTP listener.

    https://docs.oracle.com/cd/E19776-01/820-4495/ggnfu/index.html

    For example, an HTTP listener can listen on all configured IP addresses on a given port for a host by specifying the IP address 0.0.0.0. Alternatively, the HTTP listener can specify a unique IP address for each listener while using the same port.

    Either define a listener on address 0.0.0.0 to listen on all addresses of the host, or be more specific and tell it to only listen on address 192.168.0.100.