quickfix An existing connection was forcibly closed by the remote host

I used quickfix dll, my code is below but not logon

20240429-14:07:44.936 : Session FIXT.1.1:BIxxx/xxx->xxx already disconnected: Resetting…
20240429-14:07:44.954 : Session reset: New session
20240429-14:07:44.957 : Created session
20240429-14:07:45.055 : Connecting to xxx on port xxx
20240429-14:07:45.349 : Connection succeeded
20240429-14:07:45.401 : Initiated logon request
20240429-14:07:45.580 : Session FIXT.1.1:BIxxx/xxx->xxx disconnecting: System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ReceiveAsync(Socket socket, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.ReceiveAsync(Memory`1 buffer, SocketFlags socketFlags, Boolean fromNetworkStream, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
at System.Net.Sockets.NetworkStream.BeginRead(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state)
at QuickFix.SocketInitiatorThread.ReadSome(Byte[] buffer, Int32 timeoutMilliseconds)
at QuickFix.SocketInitiatorThread.Read()
at QuickFix.Transport.SocketInitiator.SocketInitiatorThreadStart(Object socketInitiatorThread)
at System.Threading.Thread.StartCallback()
End of stack trace from previous location —
at QuickFix.SocketInitiatorThread.ReadSome(Byte[] buffer, Int32 timeoutMilliseconds)
at QuickFix.SocketInitiatorThread.Read()

using QuickFix;
using QuickFix.Fields;
using QuickFix.FIXT11;
using QuickFix.Transport;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            SessionSettings settings = new SessionSettings("fix.cfg");

            string beginString = settings.Get().GetString("BeginString");
            string senderCompID = settings.Get().GetString("SenderCompID");
            string targetCompID = settings.Get().GetString("TargetCompID");
            string username = settings.Get().GetString("Username");
            string password = settings.Get().GetString("Password");

            SessionID sessionID = new SessionID(beginString, senderCompID, targetCompID);

            IApplication application = new MyQuickFixApp(username, password);
            IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
            ILogFactory logFactory = new FileLogFactory(settings);
            IMessageFactory messageFactory = new DefaultMessageFactory();

            SocketInitiator initiator = new SocketInitiator(application, storeFactory, settings, logFactory, messageFactory);

            initiator.Start();

            Console.ReadLine();

            initiator.Stop();
        }
        catch (Exception e)
        {
            Console.WriteLine("Error: " + e.ToString());
            Console.WriteLine("Press enter to exit");
            Console.ReadLine();
        }
    }
}

public class MyQuickFixApp : IApplication
{
    private string username;
    private string password;

    public MyQuickFixApp(string username, string password)
    {
        this.username = username;
        this.password = password;
    }

    public void FromAdmin(QuickFix.Message message, SessionID sessionID)
    {
        Console.WriteLine("FromAdmin: " + message);
    }

    public void FromApp(QuickFix.Message message, SessionID sessionID)
    {
        Console.WriteLine("FromApp: " + message);
    }

    public void OnCreate(SessionID sessionID)
    {
        Console.WriteLine("OnCreate: " + sessionID);
    }

    public void OnLogon(SessionID sessionID)
    {
        Console.WriteLine("OnLogon: " + sessionID);
    }

    public void OnLogout(SessionID sessionID)
    {
        Console.WriteLine("OnLogout: " + sessionID);
    }

    public void ToAdmin(QuickFix.Message message, SessionID sessionID)
    {
        if (message is Logon)
        {
            QuickFix.Message logon = new QuickFix.Message();
            logon.Header.SetField(new MsgType(MsgType.LOGON));
            logon.SetField(new Username(username));
            logon.SetField(new Password(password));
            logon.SetField(new StringField(1137, "9"));
            Session.SendToTarget(logon, sessionID);
        }

        Console.WriteLine("ToAdmin: " + message);
    }

    public void ToApp(QuickFix.Message message, SessionID sessionID)
    {
        Console.WriteLine("ToApp: " + message);
    }
}

chatgpt and professional support

New contributor

ysrkdl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật