Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Mocking server returning close frames #54

Open
TTransmit opened this issue Aug 12, 2020 · 2 comments
Open

Mocking server returning close frames #54

TTransmit opened this issue Aug 12, 2020 · 2 comments

Comments

@TTransmit
Copy link

I have an issue with my WebSocket setup that the client Android app occasionally doesn't respond to a ping of the PingFrame fast enough with a pong. This causes the web socket server to return a close frame. This is fine except that there is a bug in the reconnection logic of my app that means it occasionally doesn't reconnect. I want to be able to replicate the bug caused by the close frames being received reliably.

OkHTTP has SocketPolicy. Is there a recommended way to use SocketPolicy with MockWebServer? I've been struggling to understand how to implement SocketPolicy with either OkHTTP's MockWebServer or fabric8io's MockWebServer.

Another very nice solution would be if I could send a close frame in response to a certain message or after a certain time. e.g. .andEmit(CloseFrame())

@TTransmit TTransmit changed the title Mocking server to return close frames Feature request: Mocking server to return close frames Aug 12, 2020
@TTransmit TTransmit changed the title Feature request: Mocking server to return close frames Feature request: Mocking server returning close frames Aug 12, 2020
@TTransmit TTransmit changed the title Feature request: Mocking server returning close frames Mocking server returning close frames Aug 12, 2020
@rohanKanojia
Copy link
Member

@TTransmit: Thanks for your bug report. Would you like to create a PR for this issue?

@rohanKanojia
Copy link
Member

We use mockwebserver for mocking kubernetes API responses. There we can wait for a certain period of time and emit responses. See an example here: https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/DefaultSharedIndexInformerTest.java#L87

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants