Problem with Sending Logon Message Using SBE Over a Socket in Java

79 views Asked by At

I'm working on a project where I need to connect to a remote server via a socket in Java and send a logon message with SBE (Simple Binary Encoding) format. However, even though I'm following the correct steps and encoding the logon message, the server is reporting that it received an unknown message instead. Here are the details of my setup and the code I'm using:

  1. Project Setup:
    • I'm using a Spring Boot project.
    • I've included the SBE dependency in my pom.xml file as follows:
<dependency>
    <groupId>uk.co.real-logic</groupId>
    <artifactId>sbe-all</artifactId>
    <version>1.27.0</version>
</dependency>
Code Generation:
I generated Java classes for the decoder and encoder of each sub-message using the following command:
java -jar -Dsbe.output.dir=target/generated-sources/java \
  <local-maven-directory>/repository/uk/co/real-logic/sbe-all/1.26.0/sbe-all-1.26.0.jar \
  src/main/resources/schema.xml
Code to Connect and Send Logon Message:
I'm connecting to the server on ports 30001 to 30005.
I'm using LogonEncoder and MessageHeaderEncoder to construct and send the logon message.
Here's a snippet of my code:
try {
    for (int port = 30001; port <= 30005; port++) {
        Socket socket = new Socket("192.z.x.y", port);
        // ... (Other initialization code)

        // Construct and send the logon message
        if (port == 30001) {
            LogonEncoder logonEncoder = new LogonEncoder();
            MessageHeaderEncoder message = new MessageHeaderEncoder();
            // ... (Setting logon message fields)
            int messageLength = message.encodedLength() + logonEncoder.encodedLength();
            outStream.write(buffer.byteArray(), 0, messageLength);
            outStream.flush();
        }
    }
    // ... (Error handling and other code)
} catch (Exception e) {
    e.printStackTrace();
}
Problem:
When I run the code, I receive the following log from the server:
SBE Accepted TCP connection - Remote 192.168.249.178:59526 - Local 0.0.0.0:30001
2023/11/07 11:45:45.138481 | DROP_COP[23435-01.35] | warning  | 00 | #9025 | OEChainTCPConnectionSBEActor.hpp:76 | Warning [Invalid schemaId: 120]
2023/11/07 11:45:45.138498 | DROP_COP[23435-01.35] | warning  | 00 | #5011 | AbstractOEChainTCPConnectionActor.hpp:293 | SBE TCP Disconnecting: expected a logon message, an unknown message was sent instead - Remote 192.168.249.178:59526 - Local 0.0.0.0:30001
I suspect there might be an issue with the buffer offset or something else. Can you help me identify what could be causing the problem? please help :( This code is causing me trouble.
0

There are 0 answers