question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SocketAcceptorInterceptor receive an unexpected payload object rather than receive a setup payload object

See original GitHub issue

We create a client and server with reconnection feature. The server register a interceptor to receive the setup payload and then deserialized for authentication.

Client have another daemon thread called Thread A and send data by rsocket periodically. The sended payload data we call it payload-A.

After server is stopped and we can see the priodically sended data is failed as what we expected. After the server is started again, client begin to reconnect to the server. We can see the socket acceptor receive the setup payload data, but it is not the setup data we generated by method getAuthInfo() method. The server sidecar acceptor receive an unexpected normal payload data which is very strange.

Related server and client code:

// client 
        requesterMono = rsocketRequesterBuilder.setupRoute(SETUP_ROUTE)
            .setupData(new ObjectMapper().writeValueAsString(getAuthInfo()))
            .dataMimeType(MimeTypeUtils.parseMimeType(WellKnownMimeType.APPLICATION_JSON.getString()))
            .rsocketConnector(connector -> connector.acceptor(responder).fragment(MTU_BYTE_SIZE)
                .keepAlive(Duration.ofSeconds(KEEP_ALIVE_INTERVAL_SEC), Duration.ofSeconds(KEEP_ALIVE_MAX_TIME_SEC))
                .reconnect(Retry.fixedDelay(Integer.MAX_VALUE, Duration.ofSeconds(RSOCKET_RETRY_INTERVAL_SECONDS))
                    .doAfterRetry(retrySignal -> log.warn("RSocket client is reconnecting to get the newest connection...."))))
            .connect(TcpClientTransport.create(TcpClient.create()
                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, TCP_CONN_TIMEOUT)
                .option(ChannelOption.TCP_NODELAY, true)
                .option(ChannelOption.SO_KEEPALIVE, true)
                .host(consoleDomain)
                .port(SERVER_PORT)
                .secure(ssl -> ssl.sslContext(sslContext))));

// register a socket acceptor interceptor to receive the authentication setup payload object in the server side
    protected SocketAcceptorInterceptor genAcceptorAuthInterceptor() {
        SocketAcceptorInterceptor interceptor = acceptor -> (setup, sendingSocket) -> {
            try {
                log.info("receive an task connection try to init.");
                LocalTaskAuthInfo authInfo = new ObjectMapper().readValue(setup.getDataUtf8(), LocalTaskAuthInfo.class);

              //ignore some non-related code...
                return acceptor.accept(setup, sendingSocket);
            } catch (Exception e) {
                String errMsg = "try to accept a connection error.msg:" + ExceptionUtils.getRootCauseMessage(e);
                log.warn(errMsg, e);
                exceptionService.saveException(new SidecarRuntimeException(e));
                return Mono.error(new RSocketAuthException(errMsg));
            }
        };
        return interceptor;
    }



//server
 RSocketServer.create(routeHandler.responder()).fragment(RSocketConnConstans.MTU_BYTE_SIZE)
            .interceptors(registry -> registry.forSocketAcceptor(interceptor))
            .bind(TcpServerTransport.create(TcpServer.create()
                .option(EpollChannelOption.SO_KEEPALIVE, true)
                .option(EpollChannelOption.TCP_NODELAY, true)
                .secure(ssl -> ssl.sslContext(sslContext))
                .port(Integer.valueOf(consoleConfig.getRsocketConsolePort()))
                .doOnConnection(
                    t -> log.info("New sidecar CONNECTED. Pay attention that this is maybe a resumed connection..."))))
            .subscribe();

Expected Behavior

Receive setup payload in the socket acceptor

Actual Behavior

Receive a normal payload data.

Steps to Reproduce

Unfortuncately that we can’t reproduce it stablely. The issue occur sometimes after server is restarted. Usually after the server is restarted everything goes well.

Possible Solution

May be this is a parallel bug. It occur now and then. I know this issue may ba a little difficult. Is there any suggestion that I can take to set the breakpoint. This issue’s key point is to find out why the normal paryload data replace the setup payload data and then cause the deserialization problem.

Your Environment

  • RSocket version(s) used: rsocket-core-1.0.2 and springboot-starter-rsocket 2.3.4.RELEASE
  • Platform (eg. JVM version (javar -version) or Node version (node --version)): OpenJDK 1.8
  • OS and version (eg uname -a): Mac OS 10.15.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
rstoyanchevcommented, Mar 3, 2021

@KaimingWan after some more looking, we found the problem. The fix is available in snapshots. Not sure if you’re able to confirm the fix with 1.0.4-SNAPSHOT via https://oss.jfrog.org/artifactory/oss-snapshot-local – that would be very helpful, but either way this fix should help to address the issue.

1reaction
KaimingWancommented, Mar 5, 2021

@OlegDokuka Thanks for your explanation. I find 1.0.4 has been released yesterday and we have changed to this version. Respect for you guys’s efficient work~

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue in storing expected inbound JSON Payload com...
When trying to receive the Inbound payload from an external third-party ... expected JSON format as I am getting an array of object...
Read more >
Getting an [object Object] instead of actual data in console.log
The data is stored correctly in state and I can see it in Redux Dev tools,. But how can I see the console.log...
Read more >
Schema does not define the type of JSON values
The API defines a schema for a JSON payload, but the schema does not ... The received payloads could be blindly transformed into...
Read more >
JSON object payload gets corrupted across the boundary of ...
Unexpected character '\u000a' at payload@[17:42] (line:column), expected '"'. This error does not happen if the enricher is removed. CAUSE. This ...
Read more >
HTTP REST API and Examples — Cordra documentation
(Some Type methods may allow the use of GET rather than POST.) GET /listMethods ... GET /objects/20.5000.1234/1321d2d033b22bee1187?payload=file. Response:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found