Occurs at the time of loading the page, in addition to the parcer does not find the channel room or can not read some characters.
<p:socket onMessage="handleMessage" channel="/{room}" autoConnect="false" widgetVar='subscriber' />
Caused by:
java.lang.IllegalArgumentException: [/context/primepush/{room}] is not a valid URL fragment. Consider encoding relevant portions of the URL with [class org.ocpsoft.urlbuilder.util.Encoder]
my web.xml
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
in my bean
public void login(BLogin log) {
RequestContext requestContext = RequestContext.getCurrentInstance();
username=log.getLogNombres()+" "+log.getLogApellidos();
if(users.contains(username)) {
//loggedIn = false;
//FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Username taken", "Try with another username."));
//requestContext.update("growl");
// requestContext.execute("PF('subscriber').connect('/" + username + "')");
loggedIn = true;
}
else{
users.add(username);
requestContext.execute("PF('subscriber').connect('/" + username + "')");
loggedIn = true;
}
}
my xhtml
<f:metadata>
<f:event type="preRenderView" listener="#{chatView.login(bLoginController.getbLogin())}" />
</f:metadata>
<p:growl id="growl" showDetail="true"/>
<p:socket onMessage="handleMessage" channel="/{room}" autoConnect="false" widgetVar='subscriber' />
<script type="text/javascript">
function handleMessage(message) {
var chatContent = $(PrimeFaces.escapeClientId('form:public')),
text = (message.user) ? message.user + ':' + message.text : message.text;
chatContent.append(text + '<br />');
//keep scroll
chatContent.scrollTop(chatContent.height());
if (message.updateList) {
updateList();
}
}
</script>
I try
<p:socket onMessage="handleMessage" channel="/%7Broom%7D"
and other error
16:16:21,998 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (default task-16) Error Rendering View[/pages/home.xhtml]: java.lang.IllegalStateException: No parameter [room] was set in the pattern [/context/primepush/{room}]. Call address.set("room", value); or remove the parameter from the pattern.
The solution is to only write / room without the relatives and the connections were created correctly
<p:socket onMessage="handleMessage" channel="/room" autoConnect="false" widgetVar='subscriber' />