Connection reset by peer in audiosocket - python

in audio-socket server refrense duration call, randomly call disconnected with below exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.9/threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "/call_management/audiosocket_server/connection.py", line 228, in _process
self.conn_sock.send(types.audio + PCM_SIZE + bytes(320))
ConnectionResetError: [Errno 104] Connection reset by peer```
why occur this exception? It disconnect call, how i fix it?

Related

py4j.protocol.Py4JNetworkError: An error occurred while trying to connect to the Java server (127.0.0.1:25333)

I was running a server within a docker container, the package and image were provided by others so I can't access the code but only the tar.gz package, and I have no idea what services this container is providing.
It worked right several days ago and was not working since one restart, then I restarted it several times trying to get it to run, but it still has the same error. Is there any chance to make it run without touching the code since I cannot? Here is the error description:
P29 2022-05-25 10:59:24,923 INFO [lib_dataserver_exp.py:137] backend config: backend.conf
P29 2022-05-25 10:59:25,046 INFO [data_server.py:134] starting helper: java -Xmx32g -Dmoqi.logfile=helper -jar /root/fm-package/backend/backend.jar -c /root/fm-package/backend/backend.conf helper
Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/py4j/java_gateway.py", line 958, in _get_connection
connection = self.deque.pop()
IndexError: pop from an empty deque
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/py4j/java_gateway.py", line 1096, in start
self.socket.connect((self.address, self.port))
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/fabric/main.py", line 763, in main
*args, **kwargs
File "/opt/conda/lib/python3.6/site-packages/fabric/tasks.py", line 427, in execute
results['<local-only>'] = task.run(*args, **new_kwargs)
File "/opt/conda/lib/python3.6/site-packages/fabric/tasks.py", line 174, in run
return self.wrapped(*args, **kwargs)
File "/builds/fingerprint-core/fingerprint-matching/fm_lib/data_server/lib_dataserver_exp.py", line 151, in start_dataserver
File "/builds/fingerprint-core/fingerprint-matching/fm_lib/data_server/data_server.py", line 648, in __init__
File "/builds/fingerprint-core/fingerprint-matching/fm_lib/data_server/data_server.py", line 140, in __init__
File "/opt/conda/lib/python3.6/site-packages/py4j/java_gateway.py", line 1284, in __call__
answer = self.gateway_client.send_command(command)
File "/opt/conda/lib/python3.6/site-packages/py4j/java_gateway.py", line 1012, in send_command
connection = self._get_connection()
File "/opt/conda/lib/python3.6/site-packages/py4j/java_gateway.py", line 960, in _get_connection
connection = self._create_connection()
File "/opt/conda/lib/python3.6/site-packages/py4j/java_gateway.py", line 966, in _create_connection
connection.start()
File "/opt/conda/lib/python3.6/site-packages/py4j/java_gateway.py", line 1108, in start
raise Py4JNetworkError(msg, e)
py4j.protocol.Py4JNetworkError: An error occurred while trying to connect to the Java server (127.0.0.1:25333)
failed to send log to fluentd

How to fix rethinkdb connection refused problem?

I'm following this guide here https://github.com/flaree/Flare-Cogs/tree/master/dankmemer. I got to the import rethinkdb part but I get this error when running the r.connect('localhost', 28015).repl()
command. Been searching yesterday for a fix but couldn't find one.
r.connect('localhost', 28015).repl()
Traceback (most recent call last):
File "/root/venv/lib/python3.8/site-packages/rethinkdb/net.py", line 349, in __init__
self._socket = socket.create_connection((self.host, self.port), timeout)
File "/usr/lib/python3.8/socket.py", line 808, in create_connection
raise err
File "/usr/lib/python3.8/socket.py", line 796, 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 "<stdin>", line 1, in <module>
File "/root/venv/lib/python3.8/site-packages/rethinkdb/__init__.py", line 93, in connect
return self.make_connection(self.connection_type, *args, **kwargs)
File "/root/venv/lib/python3.8/site-packages/rethinkdb/net.py", line 830, in make_connection
return conn.reconnect(timeout=timeout)
File "/root/venv/lib/python3.8/site-packages/rethinkdb/net.py", line 696, in reconnect
return self._instance.connect(timeout)
File "/root/venv/lib/python3.8/site-packages/rethinkdb/net.py", line 538, in connect
self._socket = SocketWrapper(self, timeout)
File "/root/venv/lib/python3.8/site-packages/rethinkdb/net.py", line 437, in __init__
raise ReqlDriverError(
rethinkdb.errors.ReqlDriverError: Could not connect to localhost:28015. Error: [Errno 111] Connection refused```
You need to run rethinkdb first.
Enter your venv, and run tmux. Then run rethinkdb inside your tmux shell. This starts the rethinkdb server, and keeps it running. Close the SSH session, and open another one. Try running your code again.

Python socket.io client fails on event with dictionary and list message

I have python-socketio==4.3.1 installed, and I can connect to the socket.io server correctly.
Whenever I receive a message though, I get an exception. The data I would get would be a list on the connect event, and a dictionary on message events.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 581, in _handle_eio_message
self._handle_event(pkt.namespace, pkt.id, pkt.data)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 470, in _handle_event
r = self._trigger_event(data[0], namespace, *data[1:])
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 514, in _trigger_event
if namespace in self.handlers and event in self.handlers[namespace]:
TypeError: unhashable type: 'list'
Exception in thread Thread-6:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 581, in _handle_eio_message
self._handle_event(pkt.namespace, pkt.id, pkt.data)
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 470, in _handle_event
r = self._trigger_event(data[0], namespace, *data[1:])
File "/usr/local/lib/python3.7/site-packages/socketio/client.py", line 514, in _trigger_event
if namespace in self.handlers and event in self.handlers[namespace]:
TypeError: unhashable type: 'dict'
I am able to log the messages correctly with a node client. Any ideas?
Code is just this right now:
import socketio
io = socketio.Client()
#io.event
def connect():
print('connected')
#io.event
def message(data):
print(data)
url = '...'
io.connect(url)
Turns out the error was in the server implementation.

Pycharm debugger throws Bad file descriptor error when using dask distributed

I am using the most lightweight/simple dask multiprocessing which is the non-cluster local Client:
from distributed import Client
client = Client()
Even so: the first instance of invoking dask.bag.compute() results in the following:
Connected to pydev debugger (build 191.7141.48)
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 383, in _on_run
r = self.sock.recv(1024)
OSError: [Errno 9] Bad file descriptor
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 383, in _on_run
r = self.sock.recv(1024)
OSError: [Errno 9] Bad file descriptor
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 383, in _on_run
r = self.sock.recv(1024)
OSError: [Errno 9] Bad file descriptor
The result is that you can more or less flip a coin on whether the program will proceed or error out with a communication exception. Here is what happens when the flip comes up "tails":
Connected to pydev debugger (build 191.7141.48)
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 383, in _on_run
r = self.sock.recv(1024)
OSError: [Errno 9] Bad file descriptor
Process ForkServerProcess-3:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/distributed/core.py", line 178, in __init__
from .counter import Digest
ImportError: cannot import name 'Digest' from 'distributed.counter' (/usr/local/lib/python3.7/site-packages/distributed/counter.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 99, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/distributed/process.py", line 181, in _run
target(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/distributed/nanny.py", line 587, in _run
worker = Worker(*worker_args, **worker_kwargs)
File "/usr/local/lib/python3.7/site-packages/distributed/worker.py", line 552, in __init__
**kwargs
File "/usr/local/lib/python3.7/site-packages/distributed/node.py", line 76, in __init__
io_loop=self.io_loop,
File "/usr/local/lib/python3.7/site-packages/distributed/core.py", line 180, in __init__
self.digests = defaultdict(partial(Digest, loop=self.io_loop))
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.7/site-packages/distributed/utils.py", line 179, in ignoring
yield
SystemError: error return without exception set
distributed.nanny - WARNING - Worker process 20417 exited with status 1
Traceback (most recent call last):
File "_pydevd_frame_eval/pydevd_frame_evaluator_darwin_37_64.pyx", line 95, in _pydevd_frame_eval.pydevd_frame_evaluator_darwin_37_64.get_bytecode_while_frame_eval
KeyError: '/usr/local/lib/python3.7/site-packages/distributed/bokeh/__init__.py'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1758, in <module>
main()
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1752, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1147, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/git/huddl/python/hamspam/enron.py", line 205, in <module>
client = Client()
File "/usr/local/lib/python3.7/site-packages/distributed/client.py", line 712, in __init__
self.start(timeout=timeout)
File "/usr/local/lib/python3.7/site-packages/distributed/client.py", line 858, in start
sync(self.loop, self._start, **kwargs)
File "/usr/local/lib/python3.7/site-packages/distributed/utils.py", line 331, in sync
six.reraise(*error[0])
File "/usr/local/lib/python3.7/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/distributed/utils.py", line 316, in f
result[0] = yield future
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
value = future.result()
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 736, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/usr/local/lib/python3.7/site-packages/distributed/client.py", line 928, in _start
yield self.cluster
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
value = future.result()
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/tasks.py", line 603, in _wrap_awaitable
return (yield from awaitable.__await__())
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 736, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/usr/local/lib/python3.7/site-packages/distributed/deploy/local.py", line 284, in _start
yield [self._start_worker(**self.worker_kwargs) for i in range(n_workers)]
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 729, in run
value = future.result()
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 501, in callback
result_list.append(f.result())
File "/usr/local/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.send(value)
File "/usr/local/lib/python3.7/site-packages/distributed/deploy/local.py", line 316, in _start_worker
raise gen.TimeoutError("Worker failed to start")
tornado.util.TimeoutError: Worker failed to start
Any advice on this?
There will be even more issues/complications when trying to use a LocalCluster mode -but that will be saved for a different question.

Check if connection is closed

I'm using cherrypy and ws4py.
If the browser cut the websocket connection, any write in def received_message(self, m): would raise an error,
Exception in thread Thread-1:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/Library/Python/2.7/site-packages/ws4py/manager.py", line 310, in run
if not ws.once():
File "/Library/Python/2.7/site-packages/ws4py/websocket.py", line 388, in once
if not self.process(b):
File "/Library/Python/2.7/site-packages/ws4py/websocket.py", line 445, in process
self.close(s.closing.code, s.closing.reason)
File "/Library/Python/2.7/site-packages/ws4py/websocket.py", line 189, in close
self._write(self.stream.close(code=code, reason=reason).single(mask=self.stream.always_mask))
File "/Library/Python/2.7/site-packages/ws4py/websocket.py", line 279, in _write
self.sock.sendall(b)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
error: [Errno 32] Broken pipe
How can I tell if the connection is closed?

Categories

Resources