fvmt / quickfix-python-sample

Sample python quickfix venue and trader applications.
GNU General Public License v3.0
31 stars 19 forks source link

Socket Error: Connection reset by peer. #4

Open pavel-tashev opened 5 years ago

pavel-tashev commented 5 years ago

Hi,

When I try to make a connection in the log directory I get this message:

20190814-13:18:18.915796000 : Initiated logon request 20190814-13:18:18.933123000 : Socket Error: Connection reset by peer. 20190814-13:18:18.933173000 : Disconnecting

I have no idea but I can't connect to the remote server. According to them, I do not execute requests to their server. I followed all instruction for the installation.

To install quickfix I used this command:

pip install quickfix

Do I have to make any other configurations/settings? I suspect that there is an issue with the ports or maybe the installation of quickfix is not correct. Any suggestions?

pavel-tashev commented 5 years ago

I came closer to the issue and I think that in the config file when I add this:

SocketUseSSL=Y

It's not enough for the SSL communication to be established. I have to generate self-signed certificate which I did but still doesn't work. Any suggestions?

fvmt commented 5 years ago

Hmm After 5 years I've just tried to execute all this and it still works like a charm :D Have to notice that I've built quickfix manually from their github account. Give me some more time to investigate, but meanwhile make sure that when you are trying to connect with client, your server is already up and listening for connections. Привет!

pavel-tashev commented 5 years ago

Привет ;)

Actually what I did yesterday is to connect to two trading platforms. Let's label them (1) and (2). (1) requires SSL (+TLSv1) and (2) does not.

When I try to connect to (2) it works like a charm but when I try to connect to (1) I get the error "Socket Error: Connection reset by peer." which according to Quickfix happens when receiving messages over Socket fails (check this link: https://github.com/quickfix/quickfix/blob/dab6d9f937e3bc700a2e8be681936b0069857609/src/C%2B%2B/Exceptions.h, row 281).

Taking into account that (1) requires but (2) does not require SSL tunnel, I presume that the issue is caused by a missing self-signed certificate.

This is why the main question here is how with the help of "quickfix-python-sample" to do that? What I did is to generate a self-signed certificate (Ubuntu 18.04) and add the following lines of code in the *.cfg file.

SocketUseSSL=Y
SSLProtocol=+TLSv1
SocketKeyStore=/PATH-TO-CERTIFICATE/CERT.pem
SocketKeyStorePassword=PASSWORD

and this one as well:

SocketUseSSL=Y
SSLProtocol=+TLSv1
ServerCertificateFile=/PATH-TO-CERTIFICATE/CERT.crt
ServerCertificateKeyFile=/PATH-TO-CERTIFICATE/CERT.key
SocketKeyStorePassword=PASSWORD

Unfortunately it didn't work.

Questions:

pavel-tashev commented 5 years ago

Quick update, I used Quickfix/J with enabled SSL connection and I was able to connect to my client successfully (the trading platform). I presume that the issue we have here is that python does not establish socket connection with a self-signed certificate. The question is: How to establish a self-signed SSL connection?

Any progress on this one?