wundergraph/nextjs-typescript-postgresql-graphql-realtime-chat

Hook server on 127.0.0.1:9992 gives a ERR_CONNECTION_REFUSED

Twathik opened this issue · 6 comments

wunderctl version : 0.60.1
@wundergraph/sdk: "^0.73.0",
OS: mac os 11 big sir
node v : 17

when I start the dev server the Initial logs seems to be OK

(base) mac@Takpro nextjs-typescript-postgresql-graphql-realtime-chat % yarn dev
yarn run v1.22.17
warning ../../../package.json: No license field
$ concurrently "$npm_execpath run nextDev" "$npm_execpath run wundergraph" "$npm_execpath run browser"
warning ../../../package.json: No license field
warning ../../../package.json: No license field
warning ../../../package.json: No license field
$ next dev
$ cd .wundergraph && $npm_execpath run dev
$ wait-on "http-get://localhost:3000" && open-cli http://localhost:3000
warning ../../../../package.json: No license field
[0] ready - started server on 0.0.0.0:3000, url: http://localhost:3000
$ wunderctl up --debug
[1] 2022-02-14T20:46:56+01:00   debug   starting without env file
[1] 2022-02-14T20:46:56+01:00   info    starting WunderNode     {"version": "0.60.1", "commit": "884ce7c5053580047a8a9540cff0054a208662eb", "date": "2022-02-05T11:56:46Z", "builtBy": "ci"}
[1] 2022-02-14T20:46:56+01:00   info    api config: file polling        {"config_file_name": "generated/wundergraph.config.json"}
[1] 2022-02-14T20:46:56+01:00   debug   Analytics config        {"enable": false}
[1] {Path:/Users/mac/Desktop/test/nextjs-typescript-postgresql-graphql-realtime-chat/.wundergraph/wundergraph.config.ts Namespace:file PluginData:<nil>}
[1] {Path:/Users/mac/Desktop/test/nextjs-typescript-postgresql-graphql-realtime-chat/.wundergraph/wundergraph.hooks.ts Namespace:file PluginData:<nil>}
[1] {Path:/Users/mac/Desktop/test/nextjs-typescript-postgresql-graphql-realtime-chat/.wundergraph/generated/wundergraph.hooks.configuration.ts Namespace:file PluginData:<nil>}
[1] {Path:/Users/mac/Desktop/test/nextjs-typescript-postgresql-graphql-realtime-chat/.wundergraph/wundergraph.hooks.ts Namespace:file PluginData:<nil>}
[1] {Path:/Users/mac/Desktop/test/nextjs-typescript-postgresql-graphql-realtime-chat/.wundergraph/wundergraph.operations.ts Namespace:file PluginData:<nil>}
[1] {Path:/Users/mac/Desktop/test/nextjs-typescript-postgresql-graphql-realtime-chat/.wundergraph/generated/wundergraph.operations.configuration.ts Namespace:file PluginData:<nil>}
[1] {Path:/Users/mac/Desktop/test/nextjs-typescript-postgresql-graphql-realtime-chat/.wundergraph/generated/wundergraph.hooks.configuration.ts Namespace:file PluginData:<nil>}
[1] 2022-02-14T20:46:56+01:00   debug   updated config -> (re-)configuring server
[1] 2022-02-14T20:46:56+01:00   debug   http.Client.Transport   {"enableDebugMode": true}
[1] 2022-02-14T20:46:56+01:00   debug   configureCache  {"primaryHost": "localhost:9991", "pathPrefix": "api/main", "deploymentID": "", "cacheKind": "IN_MEMORY_CACHE", "cacheSize": 1000000000}
[1] 2022-02-14T20:46:56+01:00   debug   configuring API {"name": "api/main", "numOfOperations": 8}
[1] 2022-02-14T20:46:56+01:00   debug   create sub router       {"host": "localhost:9991", "pathPrefix": "/api/main"}
[1] 2022-02-14T20:46:56+01:00   debug   configuring CORS        {"api": "api/main", "allowedOrigins": ["http://localhost:3000"]}
[1] 2022-02-14T20:46:56+01:00   debug   api.configureCookieProvider     {"provider": "github", "providerId": "github", "pathPrefix": "api/main", "host": "localhost:9991", "clientID": "6f4093e00a7a8fec721a"}
[1] 2022-02-14T20:46:56+01:00   debug   Config Bundler: initial build successful
[1] 2022-02-14T20:46:56+01:00   debug   Config Bundler: watching for file changes       {"bundler": "hooks", "outFile": "generated/bundle/hooks.js", "externalImports": [], "fileLoaders": [".handlebars"]}
[1] 2022-02-14T20:46:56+01:00   debug   Bundler: execute script {"bundler": "hooks"}
[0] info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
[1] {"level":30,"time":1644868016635,"pid":38642,"hostname":"Takpro.local","msg":"Server listening at http://[::1]:9992"}
[1] hooks server listening at http://[::1]:9992
[1] 2022-02-14T20:46:56+01:00   debug   api.configureCookieProvider     {"provider": "oidc", "providerId": "test", "pathPrefix": "api/main", "host": "localhost:9991", "issuer": "http://keycloak.local/auth/realms/BOLT", "clientID": "bolt-client"}
[1] 2022-02-14T20:46:56+01:00   debug   registered MutationHandler      {"method": "POST", "path": "api/main/operations/AddMessage", "mock": false, "authRequired": true}
[1] 2022-02-14T20:46:56+01:00   debug   registered QueryHandler {"method": "GET", "path": "api/main/operations/AllUsers", "mock": false, "cacheEnabled": false, "cacheMaxAge": 0, "cacheStaleWhileRevalidate": 0, "cachePublic": false, "authRequired": false}
[1] 2022-02-14T20:46:56+01:00   debug   registered MutationHandler      {"method": "POST", "path": "api/main/operations/ChangeUserName", "mock": false, "authRequired": true}
[1] 2022-02-14T20:46:56+01:00   debug   registered MutationHandler      {"method": "POST", "path": "api/main/operations/DeleteAllMessagesByUserEmail", "mock": false, "authRequired": true}
[1] 2022-02-14T20:46:56+01:00   debug   registered QueryHandler {"method": "GET", "path": "api/main/operations/Messages", "mock": false, "cacheEnabled": false, "cacheMaxAge": 0, "cacheStaleWhileRevalidate": 0, "cachePublic": false, "authRequired": false}
[1] 2022-02-14T20:46:56+01:00   debug   registered QueryHandler {"method": "GET", "path": "api/main/operations/MockQuery", "mock": true, "cacheEnabled": false, "cacheMaxAge": 0, "cacheStaleWhileRevalidate": 0, "cachePublic": false, "authRequired": false}
[1] 2022-02-14T20:46:56+01:00   debug   registered QueryHandler {"method": "GET", "path": "api/main/operations/UserInfo", "mock": false, "cacheEnabled": false, "cacheMaxAge": 0, "cacheStaleWhileRevalidate": 0, "cachePublic": false, "authRequired": true}
[1] 2022-02-14T20:46:56+01:00   debug   configuring API {"name": "api/main", "numOfOperations": 8}
[1] 2022-02-14T20:46:56+01:00   info    listening on    {"addr": "localhost:9991"}
[1] 2022-02-14T20:46:57+01:00   debug   Config Bundler: initial build successful
[1] 2022-02-14T20:46:57+01:00   debug   Config Bundler: watching for file changes       {"bundler": "config", "outFile": "generated/bundle/config.js", "externalImports": [], "fileLoaders": [".handlebars"]}
[1] 2022-02-14T20:46:57+01:00   debug   Bundler: execute script {"bundler": "config"}
[0] event - compiled successfully
[0] event - build page: /
[0] wait  - compiling...
[0] event - build page: /
[0] event - build page: /
[0] event - build page: /
[0] event - build page: /
[0] event - build page: /
[0] event - build page: /
[0] event - build page: /
[0] event - build page: /
[0] event - build page: /
[0] event - build page: /
[0] (node:38632) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 / listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
[0] (Use `node --trace-warnings ...` to show where the warning was created)
[0] event - compiled successfully
[2] /Users/mac/.yarn/bin/yarn.js run browser exited with code 0
[1] 2022-02-14T20:47:01+01:00   debug   database.Source.Execute {"request": "{\"query\":\"{findManymessages(orderBy: [{id:\\\"desc\\\"}], take: 20){id message users {id name}}}\",\"variables\":{}}"}
[1] 2022-02-14T20:47:01+01:00   debug   database.Source.Execute.Error   {"request": "{\"query\":\"{findManymessages(orderBy: [{id:\\\"desc\\\"}], take: 20){id message users {id name}}}\",\"variables\":{}}", "error": "Post \"http://localhost:49601/\": dial tcp [::1]:49601: connect: connection refused"}
[1] 8:47:01 PM: 1/5 done
[1] 8:47:01 PM: wundergraph.app.schema.graphql updated
[1] 2022-02-14T20:47:01+01:00   debug   database.Source.Execute.Retry.after.Error
[1] 2022-02-14T20:47:01+01:00   debug   database.Source.Execute {"request": "{\"query\":\"{findManymessages(orderBy: [{id:\\\"desc\\\"}], take: 20){id message users {id name}}}\",\"variables\":{}}"}
[1] 2022-02-14T20:47:01+01:00   debug   database.Source.Execute.Succeed {"request": "{\"query\":\"{findManymessages(orderBy: [{id:\\\"desc\\\"}], take: 20){id message users {id name}}}\",\"variables\":{}}", "response": "{\"data\":{\"findManymessages\":[{\"id\":1,\"message\":\"Hey, welcome to the WunderChat! =)\",\"users\":{\"id\":1,\"name\":\"Jens@WunderGraph\"}}]}}"}
[1] 8:47:03 PM: generated/wundergraph.operations.configuration.ts updated
[1] 8:47:03 PM: generated/linkbuilder.ts updated
[1] 8:47:03 PM: generated/models.ts updated
[1] 8:47:03 PM: generated/CONFIGURE_AUTH_PROVIDERS.md updated
[1] 8:47:03 PM: generated/wundergraph.hooks.configuration.ts updated
[1] 8:47:03 PM: generated/jsonschema.ts updated
[1] 8:47:03 PM: generated/forms.tsx updated
[1] 8:47:03 PM: generated/client.ts updated
[1] 8:47:03 PM: generated/provider.tsx updated
[1] 8:47:03 PM: generated/hooks.ts updated
[1] 8:47:03 PM: 2/5 done
[1] 8:47:03 PM: Code generation completed.
[0] wait  - compiling...
[1] 8:47:03 PM: 3/5 done
[1] 8:47:03 PM: wundergraph.config.json updated
[1] 8:47:03 PM: 4/5 done
[1] 2022-02-14T20:47:03+01:00   debug   filePollConfig watcher.Events: Write
[1] 8:47:03 PM: wundergraph.postman.json skipped
[1] 8:47:03 PM: 5/5 done
[1] 8:47:03 PM: code generation completed
[1] 2022-02-14T20:47:03+01:00   debug   updated config -> (re-)configuring server
[1] 2022-02-14T20:47:03+01:00   debug   http.Client.Transport   {"enableDebugMode": true}
[1] 2022-02-14T20:47:03+01:00   debug   configureCache  {"primaryHost": "localhost:9991", "pathPrefix": "api/main", "deploymentID": "", "cacheKind": "IN_MEMORY_CACHE", "cacheSize": 1000000000}
[1] 2022-02-14T20:47:03+01:00   debug   configuring API {"name": "api/main", "numOfOperations": 8}
[1] 2022-02-14T20:47:03+01:00   debug   create sub router       {"host": "localhost:9991", "pathPrefix": "/api/main"}
[1] 2022-02-14T20:47:03+01:00   debug   configuring CORS        {"api": "api/main", "allowedOrigins": ["http://localhost:3000"]}
[1] 2022-02-14T20:47:03+01:00   debug   api.configureCookieProvider     {"provider": "github", "providerId": "github", "pathPrefix": "api/main", "host": "localhost:9991", "clientID": "6f4093e00a7a8fec721a"}
[1] 2022-02-14T20:47:03+01:00   debug   Config Bundler: script executed {"bundler": "config"}
[1] 2022-02-14T20:47:03+01:00   debug   api.configureCookieProvider     {"provider": "oidc", "providerId": "test", "pathPrefix": "api/main", "host": "localhost:9991", "issuer": "http://keycloak.local/auth/realms/BOLT", "clientID": "bolt-client"}
[1] 2022-02-14T20:47:03+01:00   debug   registered MutationHandler      {"method": "POST", "path": "api/main/operations/AddMessage", "mock": false, "authRequired": true}
[1] 2022-02-14T20:47:03+01:00   debug   registered QueryHandler {"method": "GET", "path": "api/main/operations/AllUsers", "mock": false, "cacheEnabled": false, "cacheMaxAge": 0, "cacheStaleWhileRevalidate": 0, "cachePublic": false, "authRequired": false}
[1] 2022-02-14T20:47:03+01:00   debug   registered MutationHandler      {"method": "POST", "path": "api/main/operations/ChangeUserName", "mock": false, "authRequired": true}
[1] 2022-02-14T20:47:03+01:00   debug   registered MutationHandler      {"method": "POST", "path": "api/main/operations/DeleteAllMessagesByUserEmail", "mock": false, "authRequired": true}
[1] 2022-02-14T20:47:03+01:00   debug   registered QueryHandler {"method": "GET", "path": "api/main/operations/Messages", "mock": false, "cacheEnabled": false, "cacheMaxAge": 0, "cacheStaleWhileRevalidate": 0, "cachePublic": false, "authRequired": false}
[1] 2022-02-14T20:47:03+01:00   debug   registered QueryHandler {"method": "GET", "path": "api/main/operations/MockQuery", "mock": true, "cacheEnabled": false, "cacheMaxAge": 0, "cacheStaleWhileRevalidate": 0, "cachePublic": false, "authRequired": false}
[1] 2022-02-14T20:47:03+01:00   debug   registered QueryHandler {"method": "GET", "path": "api/main/operations/UserInfo", "mock": false, "cacheEnabled": false, "cacheMaxAge": 0, "cacheStaleWhileRevalidate": 0, "cachePublic": false, "authRequired": true}
[1] 2022-02-14T20:47:03+01:00   debug   configuring API {"name": "api/main", "numOfOperations": 8}
[1] 2022-02-14T20:47:03+01:00   info    listening on    {"addr": "localhost:9991"}

when I attempt an authentication

[1] 2022/02/14 20:49:16 [DEBUG] POST http://127.0.0.1:9992/authentication/postAuthentication
[1] 2022/02/14 20:49:16 [ERR] POST http://127.0.0.1:9992/authentication/postAuthentication request failed: Post "http://127.0.0.1:9992/authentication/postAuthentication": dial tcp 127.0.0.1:9992: connect: connection refused
[1] 2022/02/14 20:49:16 [DEBUG] POST http://127.0.0.1:9992/authentication/postAuthentication: retrying in 1s (5 left)
[1] 2022-02-14T20:49:17+01:00   debug   database.Source.Execute {"request": "{\"query\":\"{findManymessages(orderBy: [{id:\\\"desc\\\"}], take: 20){id message users {id name}}}\",\"variables\":{}}"}
[1] 2022-02-14T20:49:17+01:00   debug   database.Source.Execute.Error   {"request": "{\"query\":\"{findManymessages(orderBy: [{id:\\\"desc\\\"}], take: 20){id message users {id name}}}\",\"variables\":{}}", "error": "Post \"http://localhost:50360/\": dial tcp [::1]:50360: connect: connection refused"}
[1] 2022/02/14 20:49:17 [ERR] POST http://127.0.0.1:9992/authentication/postAuthentication request failed: Post "http://127.0.0.1:9992/authentication/postAuthentication": dial tcp 127.0.0.1:9992: connect: connection refused
[1] 2022/02/14 20:49:17 [DEBUG] POST http://127.0.0.1:9992/authentication/postAuthentication: retrying in 2s (4 left)
[1] 2022-02-14T20:49:17+01:00   debug   database.Source.Execute.Retry.after.Error
[1] 2022-02-14T20:49:17+01:00   debug   database.Source.Execute {"request": "{\"query\":\"{findManymessages(orderBy: [{id:\\\"desc\\\"}], take: 20){id message users {id name}}}\",\"variables\":{}}"}
[1] 2022-02-14T20:49:17+01:00   debug   database.Source.Execute.Succeed {"request": "{\"query\":\"{findManymessages(orderBy: [{id:\\\"desc\\\"}], take: 20){id message users {id name}}}\",\"variables\":{}}", "response": "{\"data\":{\"findManymessages\":[{\"id\":1,\"message\":\"Hey, welcome to the WunderChat! =)\",\"users\":{\"id\":1,\"name\":\"Jens@WunderGraph\"}}]}}"}
[1] 2022/02/14 20:49:19 [ERR] POST http://127.0.0.1:9992/authentication/postAuthentication request failed: Post "http://127.0.0.1:9992/authentication/postAuthentication": dial tcp 127.0.0.1:9992: connect: connection refused
[1] 2022/02/14 20:49:19 [DEBUG] POST http://127.0.0.1:9992/authentication/postAuthentication: retrying in 4s (3 left)

It's seems that the hooks server listening at http://[::1]:9992 is not reachable from ipv4 loopback 127.0.0.1

on the browser reaching http://[::1]:9992 return

{"message":"Route GET:/ not found","error":"Not Found","statusCode":404}

so the server is responding, but 127.0.0.1:9992 gives a ERR_CONNECTION_REFUSED

the call being server side i did not figured how to fix this

I see, the hooks server is listening on ipv6, while we're only connecting on ipv4. We'll look into this.

Hi @Twathik, we released a hotfix. Please upgrade to the latest version e.g. npm install @wundergraph/sdk@0.73.3

there is still an issue with ERR_CONNECTION_REFUSED on 127.0.0.1:9992 ipv4 address in both 0.73.3 and 0.73.6

I managed to find a workaround

On mac os you have to delete ipv6 loopback entry (::1 localhost) from the /etc/hosts file, it solved the problem as the hook server listen to 127.0.0.1:9992 which is reachable

on linux it works fine

A permanent solution will be better, but for now it does the job

@Twathik thanks for letting us know. Could you try npm install @wundergraph/sdk@0.74.13?
Maybe this helps as well.

problem solved in @wundergraph/sdk@0.74.16, thanks for your effort