I’ve been attempting to play around with webhooks by creating a local endpoint. ( Using a tunneling service like ngrok is off the table for now, as I’ll need the IT to whitelist the endpoint.)
However, im getting this error…
Error: Local network requests are not allowed. To allow use ALLOW_LOCAL_NETWORK=true environment variable
@gjedlicska / @iainsproat will correct me if I’m wrong, but I believe this should go under the webhook-service's service part in the docker file, something like:
@dimitrie@iainsproat Thanks for checking this out guys. Howeve, now I’m getting another error. I have my endpoint running, and hook set on localhost:5001.
your browser is trying to use the GET method of the endpoint, if your server only provides a POST method, it wont respond successfully for browser requests. However if it works with postman, that should be good for the webhook service.
I see you are using https for the localhost url, maybe that could cause an issue here. Could you try with plain http?
Yes, as @gjedlicska said, the HTTP ERROR 405 is expected in the browser as it uses a GET http method and not a POST. It shows it can connect to the server, as does the Postman request which correctly uses POST.
So if your services are running in docker with docker-compose, the meaning of localhost is a bit different, than if you are running bare metal on the host OS. In this case, the webhook service container localhost is being asked to serve the request, which doesn’t have anything running on port 5000.
See a bit wider explanation and some possible solutions here:
If the service you are developing runs in a docker container, you can connect to the same docker network, and use its service name instead of localhost or ip.
Hi Han, this applies to any connections to localhost on the host network (i.e. your local machine) that the Speckle containers running via docker-compose might try to make.
A quick check as to whether a single container running in Docker can reach localhost is to run the following:
docker run --rm alpine/curl:3.14 -fsSL https://localhost:5001/api/convert/reverse
As the article suggests, you may have to add the --network=host flag to this to make it work, the equivalent in docker-compose is to add network_mode: host to the yaml file.
Exactly, in the current setup, where the webhook service has to talk to your handler, the webhook service is the client and your locally developed service is the server. So the Speckle webhook service needs to be able to find its way to your localhost server.
Since the Speckle containers are running in the confined docker environment they use a different network interface, than your server running on localhost.
To get around the issue (should only do this in local testing only) you can put your containers running in docker onto the same network as the host is. To do so, you need to add the network_mode: host config to your Speckle docker-compose.yaml
Once you do so and restart your speckle services, you should be able to access http://localhost:3000/graphql?query={serverInfo{version}} from a browser. If that works, the webhook service should be able to connect to your service running on localhost