The msg I am sending is actually a dict structure including some info. 
Something like,
arg = {
  'account': '12345',
  'asset': 'IO2312-C-3100.CEEX',
  'direction': 'LONG',
   'price': 10,
   'tick': 1
}
What I receive would be the same data structure including the trading result.


Yes, I am sure the client side and server side is running the same version of 
the project.


Yes, I agree with you it is not a good idea to use pickle with network data. 
But it is not my choice but zmq's choice. The pickle load and dump happen 
within zmq/sugar/socket.py.


CZ.
 


------------------ ???????? ------------------
??????:                                                                         
                                               "ZeroMQ development list"        
                                                                            
<[email protected]&gt;;
????????:&nbsp;2023??10??12??(??????) ????10:10
??????:&nbsp;"zeromq-dev"<[email protected]&gt;;

????:&nbsp;Re: [zeromq-dev] pyzmq issue: _pickle.UnpicklingError: pickle data 
was truncated



Hi,

On 10/12/23 16:05, CZ wrote:
&gt; I am running some python project based on client/server framework. It 
&gt; is something like rpclient/rpcserver. pyzmq is a very important part 
&gt; of this project. Now we are running into some trouble because of some 
&gt; errors in pyzmq. Please refer to the following error msg:
&gt; Exception in thread Thread-1:
&gt; Traceback (most recent call last):
&gt; &nbsp; File 
&gt; "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\threading.py", 
&gt; line 926, in _bootstrap_inner
&gt; &nbsp; &nbsp; self.run()
&gt; &nbsp; File 
&gt; "C:\Users\DELL\AppData\Local\Programs\Python\Python37\lib\threading.py", 
&gt; line 870, in run
&gt; &nbsp; &nbsp; self._target(*self._args, **self._kwargs)
&gt; &nbsp; File "D:\DellProjs\oly\Oly\olympos\q_core\rpc\__init__.py", line 
&gt; 372, in run
&gt; &nbsp; &nbsp; topic, data = self.__socket_sub.recv_pyobj(flags=NOBLOCK)
&gt; &nbsp; File "C:\Dev\Py37venv\lib\site-packages\zmq\sugar\socket.py", line 
&gt; 976, in recv_pyobj
&gt; &nbsp; &nbsp; return self._deserialize(msg, pickle.loads)
&gt; &nbsp; File "C:\Dev\Py37venv\lib\site-packages\zmq\sugar\socket.py", line 
&gt; 834, in _deserialize
&gt; &nbsp; &nbsp; return load(recvd)
&gt; _pickle.UnpicklingError: pickle data was truncated
&gt;
&gt; I am using Python3.7.9 (actually I tried python3.7.9 and. python3.11, 
&gt; the same error msg) in windows 11, and pyzmq 25.1.1. The msg I am 
&gt; sending is really small. No way it would blow the buffer. I am using 
&gt; PUB at server side and SUB at client side (I always saw XPUB and XSUB 
&gt; in the zmq.constants. Could they possibly be another choices). I saw 
&gt; flags have 3 different values (corret me if I was wrong), NOWAIT, 
&gt; NOBLOCK, SNDMORE. I am not sure if the choice of flags value could be 
&gt; the reason.
&gt;
&gt; Any of your input would be highly appreciated.&nbsp; Thanks!
&gt;
&gt; CZ.


You should print the string you are sending and the string you received. 
You also need to make sure the client and server use the same version of 
the project.


That said: You should never ever use pickle with network data. That's an 
instand remote code execution exploit as the string you unpickle can 
contain arbitrary code that you will just execute.


MfG

Goswin

_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to