w01 Posted November 12, 2015 Share Posted November 12, 2015 Hello everyone! I have a chat application which is based on this code http://www.sanwebe.com/2013/05/chat-using-websocket-php-socket everything is working fine until first page refresh. After that connection to the chat server is very long (even few seconds). Do you know how to fix this issue? Regards Quote Link to comment Share on other sites More sharing options...
mattstyles Posted November 13, 2015 Share Posted November 13, 2015 It is entirely dependent on the library you are using. Given that you've gone native on the clientside have you tried using a separate php module that wraps websocket functionality? Sounds like it is maybe having some delays in disconnecting and reconnecting. What happens when you connect in one tab and then open a few others and connect there? Any delay? Have you tried different browsers connection speeds? I've just finished updating a websocket library built on top of socket.io (node) and never experienced delays connecting, and never has any reported but socket.io does the heavy lifting in any case and their userbase is large so would have caught things like this. There looks like a port to PHP, called elephant.io, I think it just routes through to a small node server for the websocket stuff, maybe try that implementation (there are many other PHP only libs too) and see if you still have problems. Quote Link to comment Share on other sites More sharing options...
w01 Posted November 18, 2015 Author Share Posted November 18, 2015 Hello @mattstyles I performed few checks and: there is no problem with connecting on multiple tabs (I'm connected just after page is loaded). Problem exist only when I'm refreshing site (by F5 or just by open this same page in this same tab) Quote Link to comment Share on other sites More sharing options...
WombatTurkey Posted November 18, 2015 Share Posted November 18, 2015 This happens under nginx if you're passing the websocket port through nginx as a reverse proxy. Are you doing that by chance? I know sometimes nginx has a small delay on refresh when connecting to websocket ports. I found that using proxy_connect_timeout 1s; inside your websocket server block fixed that.. But if not under a reverse proxy, not sure man, I'm sorry.. Might have something to do with nginx timeout settings though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.