Current behavior
Server side subscription doesn't trigger when webhook url is pointing to localhost
Reproduction
prisma.yml
# server side subscriptions
subscriptions:
sendVerificationEmailForSignup:
webhook:
url: http://localhost:5000/foo
headers:
Content-Type: application/json
Authorization: Bearer myCoolTokenLolz
query: |
subscription {
user {
node {
id
email
firstName
}
}
}
local listener
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.post('/foo', function(req, res, next) {
console.log(req.body);
return res.sendStatus(200);
});
app.get('/', function(req, res) {
console.log('GET /');
res.send('hello');
});
app.listen(5000, function() {
console.log('Started on PORT 5000');
});
Expected behavior?
subscription triggers when pointing to localhost
localhost is relative to the server the Prisma Cluster is running on. Are the local listener and the Prisma Cluster on the same machine?
@marktani thanks for the quick response.
yes, they are both on my machine
Hi @everdrone - You're running Prisma in a container, right? If so, localhost is not pointing to your host machine, but to the container the Prisma server is running in. Therefore, you have to use a) the Docker host network gateway ip address OR b) use something like localtunnel.
So, when you start your "local listener" on your host machine. You could create a tunnel via lt -p 5000 -s myawesomeservice. Afterwards, you can use https://myawesomeservice.localtunnel.me as your webhook url.
Hi @akoenig, thanks for pointing me in the right direction
will give it a try as soon as i get used to the v1.7.0 cli!
isn't there an easy way to forward localhost within the docker-compose.yml file (in v1.7.1)?
shouldn't the line - 5000:5000 do the trick?
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.7
restart: always
ports:
- 4466:4466
- 5000:5000 # over here
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: mysql
active: true
host: db
port: 3306
user: root
password: prisma
db:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: prisma
No that doesn't work unfortunately. So localhost in the prisma container is not your machine, it is 127.0.0.1 within your container.
As described above, you only could create a tunnel or use the Docker network gateway ip address. If you're on macOS, this could also help.
a big 馃帀for docker.for.mac.host.internal
thank you
Most helpful comment
Hi @akoenig, thanks for pointing me in the right direction
will give it a try as soon as i get used to the
v1.7.0cli!