# Establishing a connection

1. Client sends server → [Logon `<A>`](/trading/fix/overview/session-level-messages/logon) message
2. Is client [ResetSeqNumFlag `<141>`](https://www.onixs.biz/fix-dictionary/4.4/tagNum_141.html) set to `Y`?
   - **Yes**, reset sequence numbers and proceed:
     - Server resets the next expected client sequence number
     - Server resets its own sequence number
     - Server responds with ← [Logon `<A>`](/trading/fix/overview/session-level-messages/logon) message with reset sequence number
     - Client sends server → [Heartbeat `<0>`](/trading/fix/overview/session-level-messages/heartbeat)
   - **No**, negotiate sequence numbers on both sides:
     1. Is client [MsgSeqNum `<34>`](https://www.onixs.biz/fix-dictionary/4.4/tagNum_34.html) value what the server is expecting?
        - **No**, value is greater than expected:
          - Server responds with ← [Logon `<A>`](/trading/fix/overview/session-level-messages/logon) message
          - Server sends client ← [Resend Request `<2>`](/trading/fix/overview/session-level-messages/resend-request)
          - Client sends server → [Sequence Reset `<4>`](/trading/fix/overview/session-level-messages/sequence-reset) ([GapFillFlag `<123>`](https://www.onixs.biz/fix-dictionary/4.4/tagNum_123.html) = `Y`)
        - **No**, value is less than expected:
          - Server disconnects
          - After checking what happened, client re-sends [Logon `<A>`](/trading/fix/overview/session-level-messages/logon) message with [ResetSeqNumFlag `<141>`](https://www.onixs.biz/fix-dictionary/4.4/tagNum_141.html) field set to `Y`
        - **Otherwise**:
          - server sends client ← [Heartbeat `<0>`](/trading/fix/overview/session-level-messages/heartbeat)
     2. Is server [MsgSeqNum `<34>`](https://www.onixs.biz/fix-dictionary/4.4/tagNum_34.html) value what the client is expecting?
        - **No**, value is greater than expected:
          - Server responds with ← [Logon `<A>`](/trading/fix/overview/session-level-messages/logon) message
          - Client sends server → [Resend Request `<2>`](/trading/fix/overview/session-level-messages/resend-request)
          - If the server is unable to replay the messages due to technical reasons, it may send a [Business Message Reject `<j>`](https://www.onixs.biz/fix-dictionary/4.4/msgtype_j_106.html) message with:
            - [BusinessRejectReason `<380>`](https://www.onixs.biz/fix-dictionary/4.4/tagNum_380.html) set to `0` (Other)
            - [Text `<58>`](https://www.onixs.biz/fix-dictionary/4.4/tagNum_58.html) set to `"Unable to process ResendRequest. Please contact support."`
          - If there are no issues, the server proceeds to replay the messages to the client:
            - Server responds with ← message [PossDupFlag `<43>`](https://www.onixs.biz/fix-dictionary/4.4/tagNum_43.html) = `Y`
            - Replay from server to client is complete
            - Server responds with ← [Heartbeat `<0>`](/trading/fix/overview/session-level-messages/heartbeat)
        - **No**, value is less than expected:
          - Client disconnects or sends server → [Logout `<5>`](/trading/fix/overview/session-level-messages/logout)
          - Gemini coordinates with the client to triage so the FIX connection can be re-established
        - **Otherwise**:
          - Client sends server → [Heartbeat `<0>`](/trading/fix/overview/session-level-messages/heartbeat)
3. Success! Your FIX connection is established.
