hertzbeat icon indicating copy to clipboard operation
hertzbeat copied to clipboard

[Task] <support monitoring WebSocket metrics>

Open tomsun28 opened this issue 2 years ago β€’ 14 comments

Description

support monitoring WebSocket metrics, available, response time and more.

Task List

  • [ ] support monitoring WebSocket metrics
  • [ ] add help doc

tomsun28 avatar Dec 06 '23 03:12 tomsun28

I made a request through the Java. net. Socket class, but its connect method seems to be unable to set a timeout, Here are the relevant discussions https://stackoverflow.com/questions/12976608/whats-the-connection-timeout-of-a-socket-created-with-a-connecting-constructor image

ZY945 avatar Dec 09 '23 07:12 ZY945

https://github.com/TooTallNate/Java-WebSocket This is also an option

ZY945 avatar Dec 09 '23 08:12 ZY945

Hi we can consider not supporting users to set connect timeout. About thrid library, it's up to you to decide whether to use it.πŸ‘

tomsun28 avatar Dec 09 '23 09:12 tomsun28

hi how about use java websocket api instead of socket. tcp protocol -> http protocol -> websocket protocol maybe like this, i am not sure it's ok.

   WebSocketClient client = new WebSocketClient();
   container.connectToServer(client, new URI(uri));

tomsun28 avatar Dec 09 '23 11:12 tomsun28

Bot detected the issue body's language is not English, translate it automatically. πŸ‘―πŸ‘­πŸ»πŸ§‘β€πŸ€β€πŸ§‘πŸ‘«πŸ§‘πŸΏβ€πŸ€β€πŸ§‘πŸ»πŸ‘©πŸΎβ€πŸ€β€πŸ‘¨πŸΏπŸ‘¬πŸΏ


hi how about use java websocket api instead of socket. tcp protocol -> http protocol -> websocket protocol maybe like this, i am not sure it's ok.

   WebSocketClient client = new WebSocketClient();
   container.connectToServer(client, new URI(uri));

hertzbeat avatar Dec 09 '23 11:12 hertzbeat

hi how about use java websocket api instead of socket. tcp protocol -> http protocol -> websocket protocol maybe like this, i am not sure it's ok.

   WebSocketClient client = new WebSocketClient();
   container.connectToServer(client, new URI(uri));

The socket I'm using returns the following, I can try replacing it with websocket

image

ZY945 avatar Dec 09 '23 11:12 ZY945

hi how about use java websocket api instead of socket. tcp protocol -> http protocol -> websocket protocol maybe like this, i am not sure it's ok.

   WebSocketClient client = new WebSocketClient();
   container.connectToServer(client, new URI(uri));

The websocket seems to be asynchronous and cannot confirm whether it is appropriate to store the serverHandshake response in the map

ZY945 avatar Dec 09 '23 11:12 ZY945

hi how about use java websocket api instead of socket. tcp protocol -> http protocol -> websocket protocol maybe like this, i am not sure it's ok.

   WebSocketClient client = new WebSocketClient();
   container.connectToServer(client, new URI(uri));

The websocket seems to be asynchronous and cannot confirm whether it is appropriate to store the serverHandshake response in the map If I use CountDownLatch to wait, it will keep blocking, I don't know why image

ZY945 avatar Dec 09 '23 12:12 ZY945

hi how about use java websocket api instead of socket. tcp protocol -> http protocol -> websocket protocol maybe like this, i am not sure it's ok.

   WebSocketClient client = new WebSocketClient();
   container.connectToServer(client, new URI(uri));

The websocket seems to be asynchronous and cannot confirm whether it is appropriate to store the serverHandshake response in the map If I use CountDownLatch to wait, it will keep blocking, I don't know why image

Import error..

ZY945 avatar Dec 09 '23 12:12 ZY945

hi try the uri like this String uri = "ws://localhost:8080/your-websocket-endpoint";

tomsun28 avatar Dec 09 '23 12:12 tomsun28

image

πŸ‘πŸ‘ Great!It's work, you decide which one way we use.

tomsun28 avatar Dec 09 '23 12:12 tomsun28

hi try the uri like this String uri = "ws://localhost:8080/your-websocket-endpoint";

You're right, it's true that I wrote the wrong uri,It works image and nedd the dependency

        <dependency>
            <groupId>org.java-websocket</groupId>
            <artifactId>Java-WebSocket</artifactId>
            <version>1.5.2</version>
            <scope>compile</scope>
        </dependency>

ZY945 avatar Dec 09 '23 13:12 ZY945

image

πŸ‘πŸ‘ Great!It's work, you decide which one way we use.

Extra packages needed to be introduced, and at the same time it seemed that there wasn't enough information to get the handshake, so I used the socket image

ZY945 avatar Dec 09 '23 13:12 ZY945

Extra packages needed to be introduced, and at the same time it seemed that there wasn't enough information to get the handshake, so I used the socket !

πŸ‘πŸ‘οΌ

tomsun28 avatar Dec 09 '23 13:12 tomsun28