Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Must run on port 8080? Failure ECONNREFUSED 127.0.0.1:8080 #204

Open
the-vampiire opened this issue Jan 23, 2022 · 3 comments
Open

Must run on port 8080? Failure ECONNREFUSED 127.0.0.1:8080 #204

the-vampiire opened this issue Jan 23, 2022 · 3 comments

Comments

@the-vampiire
Copy link

When i run agenda-rest -u <mongo URI> -p 8082 i get the following failure on jobs

"failCount" : 2, 
"failReason" : "failure in callback: Error: connect ECONNREFUSED 127.0.0.1:8080"

my job definitions do not use port 8080 so i was very confused.

i then ran agenda-rest on port 8080 to see if it was failing to connect to the agenda-rest API (expecting it on 8080) and the job worked!

i dont see anywhere in the code this hardcoded expectation of agenda-rest running on 8080. where is that coming from and how can it be modified to match the port passed in -p CLI option?

also a related error is the callback.url seems to invoke the agenda-rest API at that path. the job succeeded but callback failed (i had set callback.url to be another endpoint of mine to confirm how it worked). it looks like it ignores the host/port and just tries to do <agenda-rest>/path. is that expected?

@the-vampiire
Copy link
Author

for reference here is my full setup:

  1. start agenda-rest from CLI: agenda-rest -u <mongodb uri> -p 8080 (only way to work is on 8080)
  2. create a job definition: POST http://localhost:8080/api/job

request body

{
    "name" : "TestJob",
    "url" : "http://localhost:8008/webhook/:eventId",
    "method" : "GET",
    "callback" : {
        "url" : "http://localhost:8008/invoked",
        "method" : "POST"
    }
}
  1. create a once job: POST http://localhost:8080/api/job/once

request body

{
    "name" : "TestJob",           
    "interval" : "1642967160522",       
    "data": {         
        "params" : { "eventId": "61eca3a6d9dd5a296a17a8be"}    
    }
}

on my web service (running on 8008) i added handlers for GET /webhook/:eventId and POST /invoked to test the functionality of agenda-rest.

  • the job url (http://localhost:8008/webhook/:eventId) was successfully requested
  • the callback url (http://localhost:8008/invoked) did not receive a request

looking in the db i see the reason for failure is that it requests a relative path (relative to agenda-rest i imagine) from callback.url

> db.agendaJobs.findOne()
{
	"_id" : ObjectId("61edb056c694492a53f49588"),
	"name" : "TestJob",
	"data" : {
		"params" : {
			"eventId" : "61eca3a6d9dd5a296a17a8be"
		}
	},
	"type" : "normal",
	"priority" : 0,
	"nextRunAt" : null,
	"lastModifiedBy" : null,
	"lockedAt" : null,
	"lastRunAt" : ISODate("2022-01-23T19:46:00.525Z"),
	"failCount" : 1,
	"failReason" : "failure in callback: 404 - \"<!DOCTYPE html>\\n<html lang=\\\"en\\\">\\n<head>\\n<meta charset=\\\"utf-8\\\">\\n<title>Error</title>\\n</head>\\n<body>\\n<pre>Cannot POST /invoked</pre>\\n</body>\\n</html>\\n\"",
	"failedAt" : ISODate("2022-01-23T19:46:01.043Z"),
	"lastFinishedAt" : ISODate("2022-01-23T19:46:01.043Z")
}

@Jaykingamez
Copy link

hello, have you solved this issue in your fork?

@the-vampiire
Copy link
Author

the-vampiire commented Sep 5, 2022

@Jaykingamez yes. See from this commit up to this commit. The others after that were project/docker specific customization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants