NULL user objects
NULL user objects
When cycling through the active user list sometimes I come across a null user. These null users can hang around in memory for minutes at a time. These null users create all sorts of problem in my extensions. When I wrote the script I didn't account for the server to be holding a null user object. Is there any reason why the server isn't getting rid of these null user objects?
I run sfs version 1.4.2.
Thanks,
Blank_101
I run sfs version 1.4.2.
Thanks,
Blank_101
Server side. I keep a list of active users on my zone extension.Lapo wrote:Client side or server side?When cycling through the active user list sometimes I come across a null user.
How do you get the user list?
To populate the list I cycle through all users on extension init():
Code: Select all
for (var i = zone.getChannelList().iterator(); i.hasNext(); ) {
var user = _server.getUserByChannel(i.next());
if (user != null) {
userList[user.getUserId()] = user;
}
}Another way I cycle through the active users list:
Code: Select all
var recipients = [];
var zone = _server.getCurrentZone();
var roomList = zone.getRooms();
for (var i in roomList) {
var userList = roomList[i].getAllUsers();
for (var o in userList) {
recipients.push(userList[o]);
}
}I am not sure if I understand:
this code is correct
You have to check for null users because you're trying to see if a certain socket channel corresponds to a User. This is not necessarily true, so your check is correct.
Does the problem appear with the 2nd snippet of code?
this code is correct
Code: Select all
for (var i = zone.getChannelList().iterator(); i.hasNext(); ) {
var user = _server.getUserByChannel(i.next());
if (user != null) {
userList[user.getUserId()] = user;
}
}Does the problem appear with the 2nd snippet of code?
The problem does appear in the 2nd snippet of code. Also, the 1st snippet can throw the null user error as well. They both throw the same error when a null user is present on the server.Lapo wrote:I am not sure if I understand:
this code is correctYou have to check for null users because you're trying to see if a certain socket channel corresponds to a User. This is not necessarily true, so your check is correct.Code: Select all
for (var i = zone.getChannelList().iterator(); i.hasNext(); ) { var user = _server.getUserByChannel(i.next()); if (user != null) { userList[user.getUserId()] = user; } }
Does the problem appear with the 2nd snippet of code?
I've investigated some more.
1) In the first code snippet, as I already mentioned, you have to check for null objects because you're retrieving Users from their SockerChannels. It's not guaranteed that a SocketChannel has its corresponding User object, hence you should check for null values being returned
2) In the 2nd snippet the culprit should be the getAllUsers() method, however at the moment it's not really clear why this should happen.
As a workaround you can simply check for null values and discard them.
In order to go hunting for possible bugs we'd like to have more infos about the issue.
Can you reproduce the problem?
Does this happens with low traffic?
Does it seem to be happening after a certain amount of time?
The more info you can provide the quicker we can restrict the "hunt zone" and provide a solution
thanks
1) In the first code snippet, as I already mentioned, you have to check for null objects because you're retrieving Users from their SockerChannels. It's not guaranteed that a SocketChannel has its corresponding User object, hence you should check for null values being returned
2) In the 2nd snippet the culprit should be the getAllUsers() method, however at the moment it's not really clear why this should happen.
As a workaround you can simply check for null values and discard them.
In order to go hunting for possible bugs we'd like to have more infos about the issue.
Can you reproduce the problem?
Does this happens with low traffic?
Does it seem to be happening after a certain amount of time?
The more info you can provide the quicker we can restrict the "hunt zone" and provide a solution
thanks
Ok, the problem came up again yesterday. I actually managed to pinpoint the room the null user was located. I ran this code to find the culprit in the room:
Sure enough I got an output similar to this:
The above user list came from a room retreived by the room.getAllUsers() method.
To answer your questions:
Code: Select all
for (var i in userList) {
trace(userList[i]);
}Code: Select all
...
user
user
user
user
null
user
user
user
...To answer your questions:
No.Lapo wrote:Can you reproduce the problem?
I have only seen this problem occur during higher traffic. It also may be a worth while note that the extension handler queue sometimes reaches 8K messages during high traffic in which case messages start getting dropped. We have a custom login as well.Lapo wrote:Does this happens with low traffic?
No, it's random as far as I can tell. Sometimes the problem doesn't come up for days at a time. Sometimes it will come up multiple times within a few hours.Lapo wrote:Does it seem to be happening after a certain amount of time?
We've been running a stress test where 300 users where joining 10 rooms at a time, sending messages and objects and leaving the rooms at a very fast rate.
While this was running an extension was continuously monitoring the user list to trap possible NULL user objects.
Nothing was found.
The test was run on the current server engine (1.5.x). I believe it shouldn't be different from the 1.4.2 that you're using (at least in the parts interested by this test)
If you have more details let us know
While this was running an extension was continuously monitoring the user list to trap possible NULL user objects.
Nothing was found.
The test was run on the current server engine (1.5.x). I believe it shouldn't be different from the 1.4.2 that you're using (at least in the parts interested by this test)
If you have more details let us know
An update:
The problem came up again the other day. I managed to isolate the room in which the null users were located. I came up with 3 null user instances inside my main auto-join room. I loaded the admin tool like you asked and checked the auto-join room. The admin tool would only load the user list up to the point of a null user being found then the script would stop. User list updates after that point would still register, but the room info would never load and the "busy bar" at the bottom right just kept going.
The null users remained in the auto-join room indefinitely as far as I could tell. I left the server on for 2 days after the null users popped up and they never went away.
The problem came up again the other day. I managed to isolate the room in which the null users were located. I came up with 3 null user instances inside my main auto-join room. I loaded the admin tool like you asked and checked the auto-join room. The admin tool would only load the user list up to the point of a null user being found then the script would stop. User list updates after that point would still register, but the room info would never load and the "busy bar" at the bottom right just kept going.
The null users remained in the auto-join room indefinitely as far as I could tell. I left the server on for 2 days after the null users popped up and they never went away.