fix icon indicating copy to clipboard operation
fix copied to clipboard

Trouble connecting

Open julienmarie opened this issue 7 years ago • 9 comments

Hi, I'm trying to establish a connection, but it keeps on failing fix_read_conn:226 {send,<<"8=FIX.4.4|9=95|35=A|49=fxpro.xxxxxxxx|56=cServer|34=1|52=20171025-05:43:10.085|98=0|108=30|141=Y|554=xxxxxxxx|10=065|">>} fix_connection:23 {in,<<"8=FIX.4.4|9=138|35=5|34=1|49=cServer|52=20171025-05:43:11.350|56=fxpro.xxxxxxxx|58=TargetSubID is assigned with the unexpected value '', expected 'QUOTE'|10=223|">>}

In my connection parameter given by my broker, i have a SenderSubID, should I use it as well ? if yes, how?

Thanks :)

julienmarie avatar Oct 25 '17 05:10 julienmarie

Wow! First issue =)

Ok, it will be not easy, because I haven't touched it for 5 years, but let's try to help you.

First enable Debug == true:

application:set_env(fix, debug, true)

and let's check what do you send.

You need to know that every FIX server and provider has his own reading of FIX protocol. It will strictly depend on your provider. Do you have manual from them?

maxlapshin avatar Oct 25 '17 07:10 maxlapshin

What I posted earlier is with Debug on ( i'm calling the library from Elixir ). And this is the "manual" => https://help.spotware.com/FIX/model

julienmarie avatar Oct 25 '17 07:10 julienmarie

try to put hardcoded value here: https://github.com/maxlapshin/fix/blob/master/src/fix.erl#L85

sender_sub_id is known field.

maxlapshin avatar Oct 25 '17 07:10 maxlapshin

It evolves :) Now it's asking for a username ?? fix_read_conn:225 {send,<<"8=FIX.4.4|9=104|35=A|49=fxpro.xxxxxx|56=CSERVER|57=QUOTE|34=1|52=20171025-07:41:17.497|98=0|108=30|141=Y|554=xxxxxx|10=238|">>} <<56,61,70,73,88,46,52,46,52,1,57,61,57,55,1,51,53,61,53,1,51,52,61,49,1,52,57,61,67,83,69,82,86,69,82,1,53,48,61,81,85,79,84,69,1,53,50,61,50,48,49,55,49,48,50,53,45,48,55,58,52,49,58,49,55,46,54,50,49,1,53,54,61,102,120,112,114,111,46,49,48,48,55,49,55,51,54,1,53,56,61,85,115,101,114,110,97,109,101,32,105,115,32,114,101,113,117,105,114,101,100,1,49,48,61,49,51,55,1>> fix_connection:24 {in,<<"8=FIX.4.4|9=97|35=5|34=1|49=CSERVER|50=QUOTE|52=20171025-07:41:17.621|56=fxpro.xxxxx|58=Username is required|10=137|">>} <<>> fix_read_conn:162 {fix_connection,socket_closed,"h54.p.ctrader.com",5201} I'm sorry, i'm just starting with FIX protocol

julienmarie avatar Oct 25 '17 07:10 julienmarie

https://github.com/maxlapshin/fix/blob/master/src/fix_read_conn.erl#L208

add {username,...} to list of fields.

maxlapshin avatar Oct 25 '17 07:10 maxlapshin

Login works! Now I have another issue ( maybe because I'm connecting to a FOREX broker? )

fix_read_conn:304 subscribe 1 20, [{symbol,<<"1">>}, {cfi_code,"MRCXXX"}, {security_exchange,undefined}]

:fix_reader.subscribe(:fix_read, :"1") fix_read_conn:225 {send,<<"8=FIX.4.4|9=117|35=A|49=fxpro.xxxxxxx|56=cServer|57=QUOTE|34=1|52=20171025-07:52:08.144|98=0|108=30|141=Y|553=xxxxxxx|554=xxxxxxx|10=029|">>} fix_read_manager:132 {connection_failed,fix_read,logon_timeout,0} ** (exit) exited in: :gen_server.call(:fix_read, {:new_stock, :"1"}) ** (EXIT) time out (stdlib) gen_server.erl:206: :gen_server.call/2 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_reader.erl:39: :fix_reader.stock/2 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_reader.erl:21: :fix_reader.subscribe/4 iex(2)> fix_read_conn:225 {send,<<"8=FIX.4.4|9=117|35=A|49=fxpro.xxxxxxx|56=cServer|57=QUOTE|34=1|52=20171025-07:52:13.832|98=0|108=30|141=Y|553=xxxxxxx|554=xxxxxxx|10=029|">>} <<56,61,70,73,88,46,52,46,52,1,57,61,57,49,1,51,53,61,65,1,51,52,61,49,1,52,57,61,99,83,101,114,118,101,114,1,53,48,61,81,85,79,84,69,1,53,50,61,50,48,49,55,49,48,50,53,45,48,55,58,53,50,58,49,51,46,57,53,50,1,53,54,61,102,120,112,114,111,46,49,48,48,55,49,55,51,54,1,57,56,61,48,1,49,48,56,61,51,48,1,49,52,49,61,89,1,49,48,61,48,53,48,1,56,61,70,73,88,46,52,46,52,1,57,61,49,49,56,1,51,53,61,106,1,51,52,61,50,1,52,57,61,99,83,101,114,118,101,114,1,53,48,61,81,85,79,84,69,1,53,50,61,50,48,49,55,49,48,50,53,45,48,55,58,53,50,58,49,51,46,57,53,51,1,53,54,61,102,120,112,114,111,46,49,48,48,55,49,55,51,54,1,53,56,61,65,76,82,69,65,68,89,95,76,79,71,71,69,68,95,73,78,58,65,108,114,101,97,100,121,32,108,111,103,103,101,100,32,105,110,1,51,56,48,61,48,1,49,48,61,49,51,55,1>> fix_connection:24 {in,<<"8=FIX.4.4|9=91|35=A|34=1|49=cServer|50=QUOTE|52=20171025-07:52:13.952|56=fxpro.xxxxxx|98=0|108=30|141=Y|10=050|">>} <<56,61,70,73,88,46,52,46,52,1,57,61,49,49,56,1,51,53,61,106,1,51,52,61,50,1,52,57,61,99,83,101,114,118,101,114,1,53,48,61,81,85,79,84,69,1,53,50,61,50,48,49,55,49,48,50,53,45,48,55,58,53,50,58,49,51,46,57,53,51,1,53,54,61,102,120,112,114,111,46,49,48,48,55,49,55,51,54,1,53,56,61,65,76,82,69,65,68,89,95,76,79,71,71,69,68,95,73,78,58,65,108,114,101,97,100,121,32,108,111,103,103,101,100,32,105,110,1,51,56,48,61,48,1,49,48,61,49,51,55,1>> fix_connection:24 {in,<<"8=FIX.4.4|9=118|35=j|34=2|49=cServer|50=QUOTE|52=20171025-07:52:13.953|56=fxpro.xxxxxxxxx|58=ALREADY_LOGGED_IN:Already logged in|380=0|10=137|">>} <<>> fix_read_conn:304 subscribe 1 20, [{symbol,<<"1">>}, {cfi_code,"MRCXXX"}, {security_exchange,undefined}] [error] GenServer :fix_read_conn terminating ** (FunctionClauseError) no function clause matching in :fix_parser.encode_typed_field/2 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_parser.erl:2534: :fix_parser.encode_typed_field(:security_exchange, :undefined) (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix.erl:104: :fix."-encode/1-lc$^0/1-0-"/1 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix.erl:104: :fix."-encode/1-lc$^0/1-0-"/1 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix.erl:91: :fix.pack/5 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_read_conn.erl:218: :fix_read_conn.send/3 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_read_conn.erl:311: :fix_read_conn.subscribe_stock/2 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_read_conn.erl:124: :fix_read_conn.handle_call/3 (stdlib) gen_server.erl:636: :gen_server.try_handle_call/4 (stdlib) gen_server.erl:665: :gen_server.handle_msg/6 (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3 Last message (from :fix_read): {:subscribe, :"1"} [error] GenServer :fix_read terminating ** (stop) exited in: :gen_server.call(#PID<0.636.0>, {:subscribe, :"1"}) ** (EXIT) an exception was raised: ** (FunctionClauseError) no function clause matching in :fix_parser.encode_typed_field/2 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_parser.erl:2534: :fix_parser.encode_typed_field(:security_exchange, :undefined) (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix.erl:104: :fix."-encode/1-lc$^0/1-0-"/1 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix.erl:104: :fix."-encode/1-lc$^0/1-0-"/1 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix.erl:91: :fix.pack/5 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_read_conn.erl:218: :fix_read_conn.send/3 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_read_conn.erl:311: :fix_read_conn.subscribe_stock/2 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_read_conn.erl:124: :fix_read_conn.handle_call/3 (stdlib) gen_server.erl:636: :gen_server.try_handle_call/4 (stdlib) gen_server.erl:665: :gen_server.handle_msg/6 (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3 (stdlib) gen_server.erl:206: :gen_server.call/2 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_read_manager.erl:148: :fix_read_manager."-resubscribe_stocks/1-lc$^0/1-0-"/2 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_read_manager.erl:148: :fix_read_manager.resubscribe_stocks/1 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_read_manager.erl:53: :fix_read_manager.handle_info/2 (stdlib) gen_server.erl:616: :gen_server.try_dispatch/4 (stdlib) gen_server.erl:686: :gen_server.handle_msg/6 (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3 Last message: {:timeout, #Reference<0.1614520720.1195114498.123869>, :connect}

julienmarie avatar Oct 25 '17 07:10 julienmarie

58=ALREADY_LOGGED_IN:Already logged in

is because there is a try for second connection.

Are you sure that you do not have second tcp connection to them?

maxlapshin avatar Oct 25 '17 08:10 maxlapshin

Found the issue. My connection in dev environnement is a bit slow and a 500ms network timeout made the client reconnect. I get this now :

fix_read_manager:78 {unknown_fix,fix_read, {fix,<0.455.0>, {reject,<<"20171025-10:15:52.743">>,2,207,<<"V">>,2,<<"Tag not defined for this message type">>,undefined,[{sender_sub_id,<<"QUOTE">>}]},

:fix_reader.subscribe(:fix_read, :"1") fix_read_conn:225 {send,<<"8=FIX.4.4|9=117|35=A|49=fxpro.xxx|56=CSERVER|57=QUOTE|34=1|52=20171025-10:15:52.096|98=0|108=30|141=Y|553=xxx|554=xxx|10=122|">>} fix_connection:23 {in,<<"8=FIX.4.4|9=91|35=A|34=1|49=CSERVER|50=QUOTE|52=20171025-10:15:52.660|56=fxpro.xxx|98=0|108=30|141=Y|10=107|">>} fix_read_conn:304 subscribe 1 20, [{symbol,<<"1">>}, {cfi_code,"MRCXXX"}, {security_exchange,undefined}] fix_read_conn:225 {send,<<"8=FIX.4.4|9=150|35=V|49=fxpro.xxx|56=CSERVER|57=QUOTE|34=2|52=20171025-10:15:52.694|262=20|263=1|264=0|265=0|146=1|55=1|461=MRCXXX|207=0|267=3|269=0|269=1|269=2|10=187|">>} fix_connection:23 {in,<<"8=FIX.4.4|9=139|35=3|34=2|49=CSERVER|50=QUOTE|52=20171025-10:15:52.743|56=fxpro.xxx|45=2|58=Tag not defined for this message type|371=207|372=V|373=2|10=034|">>} fix_read_manager:78 {unknown_fix,fix_read, {fix,<0.455.0>, {reject,<<"20171025-10:15:52.743">>,2,207,<<"V">>,2,<<"Tag not defined for this message type">>,undefined,[{sender_sub_id,<<"QUOTE">>}]}, <<56,61,70,73,88,46,52,46,52,1,57,61,49,51,57,1,51,53,61,51,1,51,52,61,50,1,52,57,61,67,83,69,82,86,69,82,1,53,48,61,81,85,79,84,69,1,53,50,61,50,48,49,55,49,48,50,53,45,49,48,58,49,53,58,53,50,46, 55,52,51,1,53,54,61,102,120,112,114,111,46,49,48,48,55,54,50,54,52,1,52,53,61,50,1,53,56,61,84,97,103,32,110,111,116,32,100,101,102,105,110,101,100,32,102,111,114,32,116,104,105,115,32,109,101,115, 115,97,103,101,32,116,121,112,101,1,51,55,49,61,50,48,55,1,51,55,50,61,86,1,51,55,51,61,50,1,49,48,61,48,51,52,1>>}} ** (exit) exited in: :gen_server.call(:fix_read, {:new_stock, :"1"}) ** (EXIT) time out (stdlib) gen_server.erl:206: :gen_server.call/2 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_reader.erl:39: :fix_reader.stock/2 (fix) /Users/julienmarie/work/perso/code/trading/deps/fix/src/fix_reader.erl:21: :fix_reader.subscribe/4 iex(2)> fix_connection:23 {in,<<"8=FIX.4.4|9=73|35=0|34=3|49=CSERVER|50=QUOTE|52=20171025-10:16:23.416|56=fxpro.10076264|10=020|">>} fix_connection:23 {in,<<"8=FIX.4.4|9=73|35=0|34=4|49=CSERVER|50=QUOTE|52=20171025-10:16:53.416|56=fxpro.10076264|10=024|">>} fix_connection:23 {in,<<"8=FIX.4.4|9=73|35=0|34=5|49=CSERVER|50=QUOTE|52=20171025-10:17:23.416|56=fxpro.10076264|10=023|">>}

julienmarie avatar Oct 25 '17 10:10 julienmarie

Hi, I'm trying to establish a connection, but it keeps on failing 8=FIX.4.4 9=104 35=A 34=1 49=xxxx 52=20190518-00:04:16.906 56=LMXBLM 98=0 108=60 383=512 553=xxxxx 554=xxxxxx 10=241 I'm sorry, i'm just starting with FIX protocol Help me!

ghost avatar May 18 '19 00:05 ghost