-
Notifications
You must be signed in to change notification settings - Fork 662
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
Websocket state errors with production usage #550
Comments
@bmajz thanke for reporting. this seems like a tricky one to reproduce, but the 503 was a really good hint. @shanedewael and i spoke about possible causes and we identified a few things that should be handled better. i'll let him weigh in on the changes. |
@bmajz We saw the errors you received as two different issues (both of which should be addressed). For the unhandled When we looked into the second error you saw in |
Sweet — let me know when we’re good to retest! For now we jumped back to v3 |
it still doesn't work with 4.2.2. I wrote simplest rtm bot
and it cannot connect to Slack servers. Start log -
There is strange thing in |
@anfilat the logging is definitely strange, good catch! did the application crash? did you terminate the app? i don't see an error in your output. |
I think the above PR should actually fix this issue now. |
It's the full log. Application is self-terminated. There is something wrong with transitions from a child to a parent machine. |
This issue might still exist in some form or another. I'm not sure if there's a better place to put this, but I ran into a similar issue with version I had multiple async uses of the following method... (in typescript) async awaitResponseAsync():Promise<string> {
var promise = new Promise<string>(async (resolve, reject) => {
let rtmClient = new RTMClient(BOT_TOKEN);
let channelId = await this._communicationEntity.getChannelIdAsync();
rtmClient.start(null);
// wait for response
rtmClient.once(`message`, (event) => {
console.log(event);
if(event.channel == channelId) {
this._responseText = event.text;
resolve(event.text);
rtmClient.disconnect();
}
});
rtmClient.once(`error`, (err) => {
console.error(event);
reject(err);
rtmClient.disconnect();
});
});
return promise;
} It seemed as though the happenings in 1 instance of async awaitResponseAsync():Promise<string> {
var promise = new Promise<string>((resolve, reject) => {
let rtmClient = new RTMClient(BOT_TOKEN);
rtmClient.start(null);
// wait for response
rtmClient.on(`message`, async (event) => {
let channelId = await this._communicationEntity.getChannelIdAsync();
if(event.channel == channelId) {
console.log(`Response received for ${this.communicationEntity.name}`, event);
this._responseText = event.text;
resolve(event.text);
rtmClient.disconnect();
}
});
rtmClient.on(`error`, (err) => {
console.error(event);
reject(err);
rtmClient.disconnect();
});
});
return promise;
} |
@dperez3 i'm not sure I understand the problem you're describing. the two code snippets you provided seem identical (except for the additional could you help me understand what the
|
@aoberoi thank you for the quick response! I apologize, I did paste the wrong code in the second portion and I have updated it. However, you did seem to understand what I was trying to do pretty well anyway. The This did break again today and ill respond to your other points now...
Edit: The fundamental thing I'm trying to do is asynchronously ask channels (dm and otherwise) a question and wait for an answer to the question per channel. |
UpdateI've updated to async awaitResponseAsync():Promise<string> {
return await new Promise<string>(async (resolve, reject) => {
let rtmClient = new RTMClient(BOT_TOKEN);
rtmClient.start(null);
try {
for (var i = 0; i < 30; i++) {
let rtmClient = new RTMClient(BOT_TOKEN);
rtmClient.start(null);
rtmClient.disconnect();
}
} catch (err) {
console.error('Error', err);
}
// wait for response
rtmClient.on(`message`, async (event) => {
let channelId = await this.communicationEntity.getChannelIdAsync();
if(event.channel == channelId) {
console.log(`Response received for ${this.communicationEntity.name}`, event);
this._responseText = event.text;
resolve(event.text);
rtmClient.disconnect();
}
});
rtmClient.on(`error`, (err) => {
console.error(event);
reject(err);
rtmClient.disconnect();
});
});
} The bit surrounded by a
|
One issue I have found is that I am not waiting for Anyway, I'm going to clean up some things like refactor for as little instances as possible since they can take so long to connect. |
@dperez3 okay great, thanks for clarifying! now that i understand a little more about what you're trying to accomplish, i have some further suggestions.
No, that's not how the code I provided works; the promise resolves when the message being sent is acknowledged by Slack. Your problem is different. How did you send the message you are awaiting on for a response? If you sent the first message with an i don't understand the experiment above. if you start an RTM connection and then disconnect before it finishes, then its a useless RTMClient (but I do think we should do better and not throw an error - i'll create a separate issue for that). why would you want many connections with the same token? if its because you are waiting for separate responses concurrently, then i think it would be better to store information about the separate responses you are waiting for, and then use the message handler to check against that set. without knowing too much more about your app, here's an example that might be useful:
You'll notice that in this example, the Note that the example above is limited to allowing only one "unresponded" message per channel. I'm not sure if this is a realistic constraint for your app, but it seems like you were already making that assumption in your code examples, so it carried over into my example. You could remove that constraint by creating a different condition to identify whether a specific message is a "response" to the message you send, besides just checking the channel ID. |
Just to return to the original topic at hand. I just got the following KeepAlive errors on 4.2.2
|
Description
Using this in production, we often get websocket state errors that lead to us having to take the connection down. Here are is an example (not the frames may not be in order due to how our logs are processed):
We are also regularly seeing this error appear in logs:
[ERROR] @slack/client:KeepAlive Unhandled error: Failed to send message on websocket: WebSocket is not open: readyState 2 (CLOSING). Please report to @slack/client package maintainers.
What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Filling out the following details about bugs will help us solve your issue sooner.
Reproducible in:
@slack/client
version: 4.2.0node version: v6.10.3
OS version(s): alpine linux 3.7
Steps to reproduce:
Haven't been able to figure out specific repro steps unfortunately. Just these observations from production logs
Expected result:
No error
Actual result:
Errors
Attachments:
N/A
The text was updated successfully, but these errors were encountered: