Issue in creating event producer With docker frappe installation

We are trying to enable event streaming between tow sites with single bench docker installation.

When we create Event Producer it shows the following error:
requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘p1.sys.net’, port=8080): Max retries exceeded with url: /api/method/frappe.event_streaming.doctype.event_consumer.event_consumer.register_consumer?data=%7B%22event_consumer%22%3A+%22https%3A%2F%2Fp1.sys.net%22%2C+%22consumer_doctypes%22%3A+%22%5B%7B%5C%22doctype%5C%22%3A+%5C%22ToDo%5C%22%2C+%5C%22condition%5C%22%3A+null%7D%5D%22%2C+%22user%22%3A+%22m.nozili%40sys.net%22%2C+%22api_key%22%3A+%2285c3715d9b88f0f%22%2C+%22api_secret%22%3A+%229e7bd3d0fa99d16%22%7D
(Caused by NewConnectionError(‘: Failed to establish a new connection: [Errno 111] Connection refused’))

but when we install frappe-bench with lunix commend installation in VM, it show no error and work well.

Could anyone help me in this issue?

Thanks

full error path

App Versions

{
	"frappe": "13.18.0"
}

Route

Form/Event Producer/new-event-producer-1

Trackeback

Traceback (most recent call last):
  File "env/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "env/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "env/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "env/lib/python3.9/site-packages/urllib3/connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.9/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1331, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1280, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1040, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.9/http/client.py", line 980, in send
    self.connect()
  File "env/lib/python3.9/site-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
  File "env/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f700d2fe6a0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "env/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "env/lib/python3.9/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='c1.sys.net', port=8080): Max retries exceeded with url: /api/method/frappe.event_streaming.doctype.event_consumer.event_consumer.register_consumer?data=%7B%22event_consumer%22%3A+%22https%3A%2F%2Fp1.sys.net%22%2C+%22consumer_doctypes%22%3A+%22%5B%7B%5C%22doctype%5C%22%3A+%5C%22ToDo%5C%22%2C+%5C%22condition%5C%22%3A+null%7D%5D%22%2C+%22user%22%3A+%22m.nozili%40sys.net%22%2C+%22api_key%22%3A+%2285c3715d9b88f0f%22%2C+%22api_secret%22%3A+%229e7bd3d0fa99d16%22%7D (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f700d2fe6a0>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 285, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 307, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 231, in insert
    self.run_method("before_insert")
  File "apps/frappe/frappe/model/document.py", line 866, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1159, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1142, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 860, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "apps/frappe/frappe/event_streaming/doctype/event_producer/event_producer.py", line 25, in before_insert
    self.create_event_consumer()
  File "apps/frappe/frappe/event_streaming/doctype/event_producer/event_producer.py", line 80, in create_event_consumer
    response = producer_site.post_api(
  File "apps/frappe/frappe/frappeclient.py", line 301, in post_api
    res = self.session.post(self.url + "/api/method/" + method + "/",
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 590, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 677, in send
    history = [resp for resp in gen]
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 677, in <listcomp>
    history = [resp for resp in gen]
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 237, in resolve_redirects
    resp = self.send(
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "env/lib/python3.9/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='c1.sys.net', port=8080): Max retries exceeded with url: /api/method/frappe.event_streaming.doctype.event_consumer.event_consumer.register_consumer?data=%7B%22event_consumer%22%3A+%22https%3A%2F%2Fp1.sys.net%22%2C+%22consumer_doctypes%22%3A+%22%5B%7B%5C%22doctype%5C%22%3A+%5C%22ToDo%5C%22%2C+%5C%22condition%5C%22%3A+null%7D%5D%22%2C+%22user%22%3A+%22m.nozili%40sys.net%22%2C+%22api_key%22%3A+%2285c3715d9b88f0f%22%2C+%22api_secret%22%3A+%229e7bd3d0fa99d16%22%7D (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f700d2fe6a0>: Failed to establish a new connection: [Errno 111] Connection refused'))

Traceback (most recent call last):
  File "env/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "env/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "env/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "env/lib/python3.9/site-packages/urllib3/connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.9/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1331, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1280, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1040, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.9/http/client.py", line 980, in send
    self.connect()
  File "env/lib/python3.9/site-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
  File "env/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f700d2fe6a0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "env/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "env/lib/python3.9/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='c1.sys.net', port=8080): Max retries exceeded with url: /api/method/frappe.event_streaming.doctype.event_consumer.event_consumer.register_consumer?data=%7B%22event_consumer%22%3A+%22https%3A%2F%2Fp1.sys.net%22%2C+%22consumer_doctypes%22%3A+%22%5B%7B%5C%22doctype%5C%22%3A+%5C%22ToDo%5C%22%2C+%5C%22condition%5C%22%3A+null%7D%5D%22%2C+%22user%22%3A+%22m.nozili%40sys.net%22%2C+%22api_key%22%3A+%2285c3715d9b88f0f%22%2C+%22api_secret%22%3A+%229e7bd3d0fa99d16%22%7D (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f700d2fe6a0>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 68, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 31, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 67, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1208, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 21, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 285, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 307, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 231, in insert
    self.run_method("before_insert")
  File "apps/frappe/frappe/model/document.py", line 866, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1159, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1142, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 860, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "apps/frappe/frappe/event_streaming/doctype/event_producer/event_producer.py", line 25, in before_insert
    self.create_event_consumer()
  File "apps/frappe/frappe/event_streaming/doctype/event_producer/event_producer.py", line 80, in create_event_consumer
    response = producer_site.post_api(
  File "apps/frappe/frappe/frappeclient.py", line 301, in post_api
    res = self.session.post(self.url + "/api/method/" + method + "/",
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 590, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 677, in send
    history = [resp for resp in gen]
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 677, in <listcomp>
    history = [resp for resp in gen]
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 237, in resolve_redirects
    resp = self.send(
  File "env/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "env/lib/python3.9/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='c1.sys.net', port=8080): Max retries exceeded with url: /api/method/frappe.event_streaming.doctype.event_consumer.event_consumer.register_consumer?data=%7B%22event_consumer%22%3A+%22https%3A%2F%2Fp1.sys.net%22%2C+%22consumer_doctypes%22%3A+%22%5B%7B%5C%22doctype%5C%22%3A+%5C%22ToDo%5C%22%2C+%5C%22condition%5C%22%3A+null%7D%5D%22%2C+%22user%22%3A+%22m.nozili%40sys.net%22%2C+%22api_key%22%3A+%2285c3715d9b88f0f%22%2C+%22api_secret%22%3A+%229e7bd3d0fa99d16%22%7D (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f700d2fe6a0>: Failed to establish a new connection: [Errno 111] Connection refused'))

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"Event Producer\",\"name\":\"new-event-producer-1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"incoming_change\":0,\"producer_doctypes\":[{\"docstatus\":0,\"doctype\":\"Event Producer Document Type\",\"name\":\"new-event-producer-document-type-1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"status\":\"Pending\",\"use_same_name\":0,\"unsubscribe\":0,\"has_mapping\":0,\"parent\":\"new-event-producer-1\",\"parentfield\":\"producer_doctypes\",\"parenttype\":\"Event Producer\",\"idx\":1,\"ref_doctype\":\"ToDo\"}],\"producer_url\":\"https://c1.sys.net\",\"api_key\":\"5190341908a4728\",\"api_secret\":\"4325708919e2446\",\"user\":\"m.nozili@sys.net\"}",
		"action": "Save"
	},
	"btn": {
		"jQuery224099681402609727811": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 367,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs"
}

Response Data

{
	"exception": "requests.exceptions.ConnectionError: HTTPConnectionPool(host='c1.sys.net', port=8080): Max retries exceeded with url: /api/method/frappe.event_streaming.doctype.event_consumer.event_consumer.register_consumer?data=%7B%22event_consumer%22%3A+%22https%3A%2F%2Fp1.sys.net%22%2C+%22consumer_doctypes%22%3A+%22%5B%7B%5C%22doctype%5C%22%3A+%5C%22ToDo%5C%22%2C+%5C%22condition%5C%22%3A+null%7D%5D%22%2C+%22user%22%3A+%22m.nozili%40sys.net%22%2C+%22api_key%22%3A+%2285c3715d9b88f0f%22%2C+%22api_secret%22%3A+%229e7bd3d0fa99d16%22%7D (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f700d2fe6a0>: Failed to establish a new connection: [Errno 111] Connection refused'))"
}

Did you got the solution for this??

If YES, Kindly help!!

Thanks in advance!!

Check extra_hosts Compose file version 3 reference | Docker Documentation

It acts like /etc/hosts override inside containers.

Use 172.17.0.1 as ip to access anything running on docker host from container. It works on Linux.