Push and onOpen return null for @ParamPath

UI Components for JSF
Post Reply
bigzidane
Posts: 58
Joined: 21 Jan 2015, 22:16

02 Nov 2016, 16:29

I'm using PrimeFaces 6.0 and Atmosphere Run Time 2.4.3 and Tomcat 7. I'm following Chat example and are facing with 'unknown' issue which Push message works sometime and do not work sometime. I have been trying to debug to understand what the issue is but no luck so far. I'm getting stuck like more than 2 weeks to find out the root cause why sometime work and sometime doesn't

And I have another question too, the Chat show case, it is using /room, how can it work for multiple rooms? As I understand if we send /room it will send to all 'room_1', 'room_2', 'room_3' ? please advice as well.


1. pom.xml

<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces.version}</version>
</dependency>

<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.4.3</version>
</dependency>

2. web.xml

<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<load-on-startup>0</load-on-startup>
<async-supported>true</async-supported>
</servlet>

<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>

3. Resource class

@PushEndpoint(value="/{room}/{user}")
@Singleton
public class RoomResource {

@PathParam("room")
private String room;

@PathParam("user")
private String user;



@OnOpen
public void onOpen() {
logger.info("onOpen {} for room {} and user {}", new String[]{endpoint.toString(), this.room, this.user});

eventBus.publish(room + "/*", "test data");
}

We push the message as

eventBus.publish("/room_111" + "/*", "user data");

The output is
Sometime onOpen give output as

onOpen AtmosphereResource{
uuid=187feb09-c9da-4b5d-afe6-5c19c0b4868b,
transport=WEBSOCKET,
isInScope=true,
isResumed=false,
isCancelled=false,
isSuspended=true,
broadcasters=/{room}/1234,
isClosedByClient=false,
isClosedByApplication=false,
action=Action{timeout=-1, type=SUSPEND}} for room **null** and **user** null

But sometime I see room and user do have data correct.

Please advice and help.

And please help me to understand what @PushEndpoint(value="/{room}/{user}") is

If we send "/room_1/123" or "/room_2/345" , it means we push message to the same channel right?

I'm experiencing the channel is working not stable enough. Sometime the message is NOT sent to everyone subscribed to the channel. I'm totally got stuck. Please help.

Update: There are 3 cases, which onOpen happens

1.Correct one 11:29:22 INFO [http-bio-8080-exec-7]:pad.controller.TestResource.onOpen()43 - onOpen AtmosphereResource{ uuid=e6aa499b-6962-446e-a26f-f9ca1f768335, transport=WEBSOCKET, isInScope=true, isResumed=false, isCancelled=false, isSuspended=true, broadcasters=/{room_112}/9999, isClosedByClient=false, isClosedByApplication=false, action=Action{timeout=-1, type=SUSPEND}} for room {room_112} and user 9999


2.Wrong Case 1 11:27:54 INFO [http-bio-8080-exec-8]:pad.controller.TestResource.onOpen()43 - onOpen AtmosphereResource{ uuid=b43d6cea-cdcd-498f-b83b-7377130f5a34, transport=WEBSOCKET, isInScope=true, isResumed=false, isCancelled=false, isSuspended=true, broadcasters=/{room_112};jsessionid=9082465FABC76CC67477F2BC8C513D7A/9999, isClosedByClient=false, isClosedByApplication=false, action=Action{timeout=-1, type=SUSPEND}} for room {room_112};jsessionid=9082465FABC76CC67477F2BC8C513D7A and user 9999


3.Wrong Case 2 11:29:06 INFO [http-bio-8080-exec-2]:pad.controller.TestResource.onOpen()43 - onOpen AtmosphereResource{ uuid=a34f7912-47ac-4f22-a7d5-f56a545bcea5, transport=WEBSOCKET, isInScope=true, isResumed=false, isCancelled=false, isSuspended=true, broadcasters=/{room_112}/9999, isClosedByClient=false, isClosedByApplication=false, action=Action{timeout=-1, type=SUSPEND}} for room null and user null

bigzidane
Posts: 58
Joined: 21 Jan 2015, 22:16

03 Nov 2016, 16:58

Anyone please help?

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 30 guests