Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chrome70 + stompjs + sockjs-client + java spring boot 2.0 connect too slow #470

Closed
xzzh999 opened this issue Jan 25, 2019 · 7 comments
Closed

Comments

@xzzh999
Copy link

xzzh999 commented Jan 25, 2019

chrome: 70.0.3538.67
stompjs: "^2.3.3",
sockjs-client: "^1.3.0",
spring boot use websocket: 2.0.2.RELEASE

As the title say, when i print the timestamp of connect function, it takes nearly 6 or 12 seconds or even failed to establish the connection, why it's so slow?

Here is the client side code:

addStomp(state, url) {
            if (!state.stompClients.has(url))
                state.stompClients.set(url, Stomp.over(new SockJS(url)));
        },
startSignalMonitor(context, { url, subUrl, callBack, errCallBack }) {
            return new Promise((resolve, reject) => {
                let subscribeClient;
                context.commit('addStomp', config.base_url_name+url)
                let stompClient = context.state.stompClients.get(config.base_url_name+url)
                stompClient.debug = msg => { };
                if (stompClient.connected) {
                    subscribeClient = stompClient.subscribe(subUrl, callBack, errCallBack)
                    resolve(subscribeClient)
                }
                else {
                    // TOO SLOW HERE!!!
                    stompClient.connect({}, () => {
                        subscribeClient = stompClient.subscribe(subUrl, callBack, errCallBack)
                        resolve(subscribeClient)
                    })
                }
            })
        }

Need u help, thanks!

@brycekahle
Copy link
Contributor

I cannot debug your performance issues for you. I suggest you add timing along your request path to find out where the latency is coming from.

@xzzh999
Copy link
Author

xzzh999 commented Jan 30, 2019

@brycekahle
Thank u for your reply, i have debugged it and found it's blocked on the connect function, maybe i should set a transport when create the object? what are the possible reasons for the connect function is too slow?

@brycekahle
Copy link
Contributor

@xzzh999 The problem is likely your server, not the client.

@xzzh999
Copy link
Author

xzzh999 commented Feb 18, 2019

@brycekahle
I found when i add a prefix base url, this will happen, eg:

In client side (fast)

//OK
ws://localhost:8081/ws/endpointChat   

In client side (slow or failed)

//SLOW or FAILED
ws://localhost:8081/MyServer/ws/endpointChat   

In server side (spring boot application.properties)

server.servlet.contextPath=/MyServer

I use vue.js 2.0 and webpack.

@xzzh999
Copy link
Author

xzzh999 commented Feb 20, 2019

@brycekahle
When i use proxy table to proxy websocket, the problem comes!(too slow)
Here is the print:

@brycekahle
Copy link
Contributor

brycekahle commented Feb 21, 2019

@xzzh999 You might want to fix the obvious error shown in your log.

@xzzh999
Copy link
Author

xzzh999 commented Feb 22, 2019

@brycekahle
Thank you for your reply.
The bug is confirmed, here is the reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants