aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/AsyncSocketServlet.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/api/AsyncSocketServlet.java')
-rw-r--r--src/org/traccar/api/AsyncSocketServlet.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/org/traccar/api/AsyncSocketServlet.java b/src/org/traccar/api/AsyncSocketServlet.java
index edfa8939b..ef6cef732 100644
--- a/src/org/traccar/api/AsyncSocketServlet.java
+++ b/src/org/traccar/api/AsyncSocketServlet.java
@@ -33,8 +33,12 @@ public class AsyncSocketServlet extends WebSocketServlet {
factory.setCreator(new WebSocketCreator() {
@Override
public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {
- long userId = (Long) req.getSession().getAttribute(SessionResource.USER_ID_KEY);
- return new AsyncSocket(userId);
+ if (req.getSession() != null) {
+ long userId = (Long) req.getSession().getAttribute(SessionResource.USER_ID_KEY);
+ return new AsyncSocket(userId);
+ } else {
+ return null;
+ }
}
});
}