Multiple stream Connections to FIX API

Created at 06 Dec 2017, 22:17
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
obaum1@gmail.com's avatar

obaum1@gmail.com

Joined 06.06.2017

Multiple stream Connections to FIX API
06 Dec 2017, 22:17


Hey Guys :)

When I try to open the second one I get an error message, "An existing connection was forcibly closed by the remote host"

How can I open two or more connections to the FIX API?

Thanks!!


@obaum1@gmail.com
Replies

Spotware
07 Dec 2017, 10:35

Hello Obaum,

It is not possible to have two connections to a single set of credentials. It is only possible to maintain one connection at a time. 

Many thanks,

cTrader Team


@Spotware

obaum1@gmail.com
13 Dec 2017, 01:48

Hey Team :)

Thanks for the reply!!
I have bot running in one machine and I want to access the same account form a custom view I build i build for debug.
How can I make it work?

Thanks!!


@obaum1@gmail.com

#EOL
13 Dec 2017, 12:23

You can have as many connections as you need, just use unique SenderSubID (tag 50) for every outgoing message in one session


@#EOL

obaum1@gmail.com
14 Dec 2017, 02:25

Hey #EOL,

Thanks for the reply!!
But it doesn't work for me. I get an empty string from the stream in the first response and it dies.

Any ideas? 

The Spotware team says "not possible to have two connections to a single set of credentials."
I tried opening two applications(with two sets credentials.) one for each client and, still doe not work.
Any ideas here? 

Thanks!!


@obaum1@gmail.com

#EOL
14 Dec 2017, 16:29

what application do you use?

does it provide and FIX log?

can you share them?


@#EOL

obaum1@gmail.com
20 Dec 2017, 14:11

Hey #EOL :)

doing what you wrote -> "just use unique SenderSubID" solved the problem!!
Thank you for that!!!!!


@obaum1@gmail.com

w.zacharewicz
25 Jul 2018, 03:21

Hello #EOL

I have the same problem and unfortunately I can't make it work.
I create two streams (one for TRADE and one for QUOTE) on diferent ports.
As soon as I connect to host with second stream first stops working.
Could you be more specific how you maneged to do that?
Thanks in advance.


@w.zacharewicz

obaum1@gmail.com
25 Jul 2018, 03:38

Hey w.zacharewicz,

senderSubID = // unique string

For each stream connection check if you are using unique SenderSubID (tag 50= in FIX message)

this is what did it for me..


@obaum1@gmail.com

w.zacharewicz
25 Jul 2018, 22:16

Hi. thanks for your reply.
I'm using unique SenderSubID (I use "QUOTE" for quote stream and "TRADE" for trade stream).
The problem is that I don't even need to send logon messege on second stream. After connecting
to host on second port, first connection is not valid anymore. So I'm pretty sure my problem is not about 
SenderSubID. I have two similar methods which initiate connection:

       private int _pricePort = 5211;
       private int _tradePort = 5212;
       private string _host = "h50.p.ctrader.com";

       public void InitQuoteSSL()
        {
            m_quoteClient = new TcpClient(_host, _quotePort);
            m_quoteStreamSSL = new SslStream(m_quoteClient.GetStream(), false,
                        new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
            m_quoteStreamSSL.AuthenticateAsClient(_host);
        }

        public void InitTradeSSL()
        {
            m_tradeClient = new TcpClient(_host, _tradePort);
            m_tradeStreamSSL = new SslStream(m_tradeClient.GetStream(), false,
                        new RemoteCertificateValidationCallback(ValidateServerCertificate), null);
            m_tradeStreamSSL.AuthenticateAsClient(_host);
        }

First I call InitTradeSSL and after that every trade message works fine. As soon as I call InitQuoteSSL trade messages fail.
What am I doing wrong?


@w.zacharewicz

w.zacharewicz
26 Jul 2018, 00:58

Correction: Actually I was wrong. I need to send quote logon message to make trade messages fail. But for sure I use different SenderSubID for both streams.


@w.zacharewicz

obaum1@gmail.com
27 Jul 2018, 01:03

Hey, 

Can you share the request that work and the one that breaks?


@obaum1@gmail.com

w.zacharewicz
30 Jul 2018, 00:30

Hey.
Here are logon messages:

"8=FIX.4.4|9=113|35=A|49=icmarkets.3337760|56=cServer|57=TRADE|50=TRADE|34=1|52=20180728-01:10:05|98=0|108=0|553=3337760|554=xxxx|10=135|"

"8=FIX.4.4|9=114|35=A|49=icmarkets.3337760|56=cServer|57=QUOTE|50=QUOTE|34=2|52=20180728-01:12:25|98=0|108=30|553=3337760|554=xxxx|10=252|"

After first login every TRADE message works. After second it's not working anymore.
Any ideas? Thanks for helping.


@w.zacharewicz

obaum1@gmail.com
02 Aug 2018, 13:21

Hey w.zacharewicz,

from the logon messages you submitted I see that Tag 34 have a joined message counter.
*Tag 34 should have separate counter.
Trade: |34=1|
Price: |34=1|


@obaum1@gmail.com

w.zacharewicz
03 Aug 2018, 02:15

Wow!
I can't believe it but it's working!! Thanks a lot!!!
To be honest I was very sceptic that this could be a reason, but it looks that you were right!
Thank you!!! :)


@w.zacharewicz

w.zacharewicz
03 Aug 2018, 09:09

It looks that I was happy too soon. :(
For unknown reason my QUOTE login message resets the connection.
I didn't notice that and was happy that my TRADE messeges are working after QUOTE logon.
Unfortonately connectios is reset even if I want to start only QUOTE connection. Here is my message:

8=FIX.4.4|9=114|35=A|49=icmarkets.3337760|56=cServer|57=QUOTE|50=QUOTE|34=1|52=20180728-01:12:25|98=0|108=30|553=3337760|554=xxxx|10=205|

After that I'm getting :
Connection reset by remote peer (WSAECONNRESET)

server :
h50.p.ctrader.com
QUOTE port: 5211

Any ideas?
Thanks in advance.

 

 


@w.zacharewicz

obaum1@gmail.com
03 Aug 2018, 14:02

Hey, 

you are remembering to add 1 after each message to tag 34=?

Tag=34 is the message number and for each message you need to increase by 1.

Example:

TRADE:

        1) Login message: 34=1

        2) Next message: 34=2

Price:

         1) Login message: 34=1

         2) Next message: 34=2

You need  a separate counter for each-of-them. one for the TRADE and one for the Price.

 


@obaum1@gmail.com

w.zacharewicz
06 Aug 2018, 23:57

Hey.
Yes, I remember :)
I found the problem. For some reason QUOTE was not working if tag 50 was also "QUOTE". After I changed to "PRICE" it started to work.
Anyway thanks. Your posts were very useful. I didn't know that  QUOTE and TRADE should have saparate counters.

Cheers


@w.zacharewicz