Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some remote peers remain connected even after calling close on TcpDuplexConnection #226

Open
viglucci opened this issue May 8, 2022 · 1 comment
Labels
1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release

Comments

@viglucci
Copy link
Member

viglucci commented May 8, 2022

Expected Behavior

Remote peer is disconnected when calling this.socket.end() in TcpDuplexConnection.close().

Actual Behavior

Some remote peers (clients) do not respect the end() call and are able to still transmit data to the server, which results in NPEs and other undefined behavior.

This behavior was experienced from a .Net TCP Client in Unity RSocket.

Steps to Reproduce

Not available.

Possible Solution

TcpDuplexConnection may need to additionally, or in lieu of end(), call destroy() on this.socket when close is called.

Your Environment

  • RSocket version(s) used: 1.0.0-alpha.1
  • Other relevant libraries versions (eg. netty, ...): n/a
  • Platform (eg. JVM version (javar -version) or Node version (node --version)): node: v16.13.1
  • OS and version (eg uname -a): n/a
@viglucci viglucci added the 1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release label May 8, 2022
@huahouye
Copy link

@viglucci I believe WebsocketDuplexConnection has the same issue. Connection can not be closed from client side manually by calling rsocket.close(), session still exist on server side (resume feature is enabled).

Environment

## client side (Frontend):
rsocket-js: 1.0.0-alpha.1
react js: 18

## server side:
spring-boot-starter-rsocket: 3.0.0-M3
var transport = new WebsocketClientTransport({
    debug: true,
    url: serverUrl,
    wsCreator: (url) => {
        var ws = new WebSocket(url)
        ws.onopen = (ev) => {
            console.log("WebSocket onopen");
        }
        ws.onmessage = (ev) => {
            console.log("WebSocket onmessage");
        }
        ws.onclose = (ev) => {
            console.log("WebSocket onclose");
        }
        ws.onerror = (ev) => {
            console.log("WebSocket onerror");
        }
        return ws
    },
})

web browser console log output and server side log looks like below when call rsocket.close():

WebSocket onclose
WebSocket onopen
WebSocket onmessage
13:22:10.819 [default] [reactor-http-epoll-2] DEBUG i.r.r.InMemoryResumableFramesStore - Side[server]|Session[1]. Paused at position[0] 
13:22:10.819 [default] [reactor-http-epoll-2] DEBUG i.r.r.InMemoryResumableFramesStore - Side[server]|Session[1]. Disconnected at Position[0] and ImpliedPosition[0] 
13:22:10.820 [default] [reactor-http-epoll-2] DEBUG i.r.resume.ResumableDuplexConnection - Side[server]|Session[1]|DuplexConnection[1]. Disconnected 
13:22:10.820 [default] [reactor-http-epoll-2] DEBUG i.r.resume.ServerRSocketSession - Side[server]|Session[1]. Connection is lost. Trying to timeout the active session 
13:22:16.558 [default] [reactor-http-epoll-3] DEBUG io.rsocket.FrameLogger - receiving -> 
Frame => Stream ID: 0 Type: RESUME Flags: 0b0 Length: 29
Data:
 
13:22:16.558 [default] [reactor-http-epoll-3] DEBUG i.r.resume.ServerRSocketSession - Side[server]|Session[1]. New DuplexConnection received. 
13:22:16.559 [default] [reactor-http-epoll-3] DEBUG i.r.resume.ServerRSocketSession - Side[server]|Session[1]. Resume FRAME received. ServerResumeState[impliedPosition[0], position[0]]. ClientResumeState[remoteImpliedPosition[310], remotePosition[0]] 
13:22:16.559 [default] [reactor-http-epoll-3] DEBUG i.r.r.InMemoryResumableFramesStore - Side[server]|Session[1]. Removed frames from cache to position[310]. CacheSize[0] 
13:22:16.559 [default] [reactor-http-epoll-3] DEBUG io.rsocket.FrameLogger - sending -> 
Frame => Stream ID: 0 Type: RESUME_OK Flags: 0b0 Length: 14
Data:
 
13:22:16.559 [default] [reactor-http-epoll-3] DEBUG i.r.resume.ServerRSocketSession - Side[server]|Session[1]. ResumeOKFrame[impliedPosition[0]] has been sent 
13:22:16.559 [default] [reactor-http-epoll-3] DEBUG i.r.resume.ServerRSocketSession - Side[server]|Session[1]. Session has been resumed successfully 
13:22:16.559 [default] [reactor-http-epoll-3] DEBUG i.r.resume.ResumableDuplexConnection - Side[server]|Session[1]|DuplexConnection[2]. Connecting 
13:22:16.559 [default] [reactor-http-epoll-3] DEBUG i.r.r.InMemoryResumableFramesStore - Side[server]|Session[1]. Resumed at position[0] 
13:22:16.559 [default] [reactor-http-epoll-3] DEBUG i.r.r.InMemoryResumableFramesStore - Side[server]|Session[1]. Connected at Position[310] and ImpliedPosition[0] 
13:23:16.560 [default] [parallel-8] DEBUG io.rsocket.FrameLogger - sending -> 
Frame => Stream ID: 0 Type: KEEPALIVE Flags: 0b10000000 Length: 14
Data:
 
13:23:16.610 [default] [reactor-http-epoll-3] DEBUG io.rsocket.FrameLogger - receiving -> 
Frame => Stream ID: 0 Type: KEEPALIVE Flags: 0b0 Length: 14
Data:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release
Projects
None yet
Development

No branches or pull requests

2 participants