[solved] AWS Elastic Beanstalk hooks issue

The problem is that the server version on heroku runs without problems, but when it deployed on aws I get a “Cannot POST /hooks” error.
image
Can you tell me what the problem may be?

Logs from server:

172.31.91.215 - - [24/Feb/2023:14:20:34 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.33.212 - - [24/Feb/2023:14:20:37 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.33.212 - - [24/Feb/2023:14:20:44 +0000] "OPTIONS /server/functions/getPluginSpecs HTTP/1.1" 204 0 "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" "188.163.43.216"
172.31.33.212 - - [24/Feb/2023:14:20:44 +0000] "OPTIONS /server/functions/getPluginSpecs HTTP/1.1" 204 0 "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" "188.163.43.216"
172.31.33.212 - - [24/Feb/2023:14:20:44 +0000] "POST /server/functions/getPluginSpecs HTTP/1.1" 200 13 "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" "188.163.43.216"
172.31.33.212 - - [24/Feb/2023:14:20:44 +0000] "POST /server/functions/getPluginSpecs HTTP/1.1" 200 13 "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" "188.163.43.216"
172.31.33.212 - - [24/Feb/2023:14:20:45 +0000] "OPTIONS /server/functions/getTokenBalances HTTP/1.1" 204 0 "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" "188.163.43.216"
172.31.33.212 - - [24/Feb/2023:14:20:47 +0000] "POST /server/functions/getTokenBalances HTTP/1.1" 200 9654 "http://localhost:5000/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" "188.163.43.216"
172.31.91.215 - - [24/Feb/2023:14:20:49 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.33.212 - - [24/Feb/2023:14:20:52 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.91.215 - - [24/Feb/2023:14:21:04 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.33.212 - - [24/Feb/2023:14:21:07 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.33.212 - - [24/Feb/2023:14:21:13 +0000] "POST /hooks HTTP/1.1" 404 145 "-" "PostmanRuntime/7.29.2" "188.163.43.216"
172.31.33.212 - - [24/Feb/2023:14:21:15 +0000] "POST /hooks HTTP/1.1" 404 145 "-" "PostmanRuntime/7.29.2" "188.163.43.216"
172.31.91.215 - - [24/Feb/2023:14:21:19 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"

it looks like that route doesn’t exists with /hooks, it returns 404 error, it looks like you make that request from postman?

Yes, it was from postman

Some logs from heroku with 200 code from admin.moralis stream, 401 from postman, and 404 get from browser

2023-02-24T13:57:22.744058+00:00 heroku[router]: at=info method=POST path="/streams-webhook" host=olegs-server.herokuapp.com request_id=aea199bb-35ed-492e-b790-d3b1ee945a79 fwd="35.156.247.43" dyno=web.1 connect=0ms service=2ms status=200 bytes=255 protocol=https

2023-02-24T14:02:02.162640+00:00 heroku[router]: at=info method=GET path="/" host=olegs-server.herokuapp.com request_id=80da3325-7972-472d-99fd-c90aa1813a84 fwd="188.163.43.216" dyno=web.1 connect=0ms service=2ms status=404 bytes=415 protocol=https

2023-02-24T14:02:15.285129+00:00 heroku[router]: at=info method=POST path="/streams-webhook" host=olegs-server.herokuapp.com request_id=8f439f1e-f8a1-485f-a359-ba537bb71bf4 fwd="188.163.43.216" dyno=web.1 connect=0ms service=1ms status=401 bytes=285 protocol=https

2023-02-24T14:03:26.449520+00:00 heroku[router]: at=info method=POST path="/streams-webhook" host=olegs-server.herokuapp.com request_id=8967d8de-093f-47fe-a1df-8a3c9fc21d8a fwd="188.163.43.216" dyno=web.1 connect=0ms service=1ms status=401 bytes=285 protocol=https

2023-02-24T14:27:45.661474+00:00 heroku[router]: at=info method=GET path="/streams-webhook" host=olegs-server.herokuapp.com request_id=0f210074-4eae-4e3b-8d43-1c663d677709 fwd="188.163.43.216" dyno=web.1 connect=0ms service=1ms status=404 bytes=430 protocol=https

2023-02-24T14:27:51.984291+00:00 heroku[router]: at=info method=GET path="/streams-webhook" host=olegs-server.herokuapp.com request_id=a29f8d4d-e6ff-40cb-8304-530ad83dd2f1 fwd="188.163.43.216" dyno=web.1 connect=0ms service=4ms status=404 bytes=430 protocol=https

here it looks like it is a different path

In config vars i changed hooks path

Change it back

172.31.33.212 - - [24/Feb/2023:14:34:07 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.91.215 - - [24/Feb/2023:14:34:20 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.91.215 - - [24/Feb/2023:14:34:22 +0000] "GET /hooks HTTP/1.1" 404 144 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" "188.163.43.216"
172.31.33.212 - - [24/Feb/2023:14:34:22 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.91.215 - - [24/Feb/2023:14:34:32 +0000] "GET /streams-webhook HTTP/1.1" 404 154 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" "188.163.43.216"
172.31.91.215 - - [24/Feb/2023:14:34:35 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.33.212 - - [24/Feb/2023:14:34:37 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.91.215 - - [24/Feb/2023:14:34:37 +0000] "POST /streams-webhook HTTP/1.1" 404 155 "-" "PostmanRuntime/7.29.2" "188.163.43.216"
172.31.33.212 - - [24/Feb/2023:14:35:52 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.91.215 - - [24/Feb/2023:14:35:57 +0000] "POST /hooks HTTP/1.1" 404 145 "-" "PostmanRuntime/7.29.2" "188.163.43.216"
172.31.91.215 - - [24/Feb/2023:14:36:05 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.33.212 - - [24/Feb/2023:14:36:07 +0000] "GET / HTTP/1.1" 404 139 "-" "ELB-HealthChecker/2.0" "-"
172.31.91.215 - - [24/Feb/2023:14:36:08 +0000] "POST /streams-webhook HTTP/1.1" 404 155 "-" "PostmanRuntime/7.29.2" "188.163.43.216"

maybe it is something related to that path, are there any other differences between the server config that works on heroku and one that doesn’t work on aws?

found that the “streams” path works, but why this if the configs have a different path?

@cryptokid we can close the issue. The problem was that i used code below

app.use(
  streamsSync(parseServer, {
    apiKey: config.MORALIS_API_KEY,
    webhookUrl: '/streams-webhook',
  }),
)

instead of

app.use(
  streamsSync(parseServer, {
    apiKey: config.MORALIS_API_KEY,
    webhookUrl: config.STREAMS_WEBHOOK_URL,
  }),
)
1 Like