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

Failed to send chat message when I should perform an action in 1 second #9

Open
double-beep opened this issue Oct 7, 2020 · 0 comments

Comments

@double-beep
Copy link
Member

Sending multiple chat messages in chat doesn't work if the wait period is one second. For example, here's the log for sending three messages:

2020-10-07 14:35:21 DEBUG Room:171 - New fkey retrieved for room xxxxxx is abcdefhijkl
2020-10-07 14:35:22 DEBUG Room:188 - Connecting to chat WebSocket at URL wss://chat.sockets.stackexchange.com/events/blahblahb?l=105104883 for room 215402
2020-10-07 14:35:23 DEBUG Room:212 - WebSocket session successfully opened in room xxxxx.
2020-10-07 14:35:23 INFO  Room:263 - Task added - sending message '1st message' to room xxxxx.
2020-10-07 14:35:23 INFO  Room:263 - Task added - sending message '2nd message' to room xxxxxx.
2020-10-07 14:35:23 INFO  Room:263 - Task added - sending message '3rd message' to room xxxxxx.
2020-10-07 14:35:23 DEBUG Room:475 - Leaving room xxxxxx on STACK_OVERFLOW
2020-10-07 14:35:23 DEBUG Room:277 - Message '1st' sent to room xxxxxx, raw result: {"id":12345678,"time":1602081323}
2020-10-07 14:35:23 DEBUG Room:218 - WebSocket session successfully closed in room xxxxxx.
2020-10-07 14:35:23 DEBUG Room:277 - Message '2nd' sent to room xxxxxx, raw result: {"id":123456,"time":1602081323}
2020-10-07 14:35:23 DEBUG Room:149 - Tried to POST to URL https://chat.stackoverflow.com/chats/215402/messages/new with data [text, 3rd] but was throttled, retrying in 2 seconds
2020-10-07 14:35:25 DEBUG Room:277 - Message '3rd' sent to room xxxxxx, raw result: {"id":12345678,"time":1602081325}

Sometimes, though, it fails with this log:

java.util.concurrent.CompletionException: org.sobotics.chatexchange.chat.ChatOperationException: The chat operation failed with the message: You can perform this action again in 1 second.
        at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
        at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1702)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.sobotics.chatexchange.chat.ChatOperationException: The chat operation failed with the message: You can perform this action again in 1 second.
        at org.sobotics.chatexchange.chat.Room.post(Room.java:155)
        at org.sobotics.chatexchange.chat.Room.post(Room.java:132)
        at org.sobotics.chatexchange.chat.Room.lambda$send$11(Room.java:276)
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
        ... 6 more

This is probably because of this line:

private static final Pattern TRY_AGAIN_PATTERN = Pattern.compile("You can perform this action again in (\\d+) seconds");

1 second doesn't contain s, thus it understands this as a different exception.

double-beep added a commit to double-beep/chatexchange that referenced this issue Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant