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

server.servlet.contextPath with websocket #15973

Closed
xzzh999 opened this issue Feb 18, 2019 · 6 comments
Closed

server.servlet.contextPath with websocket #15973

xzzh999 opened this issue Feb 18, 2019 · 6 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@xzzh999
Copy link

xzzh999 commented Feb 18, 2019

Hi~ Nice work!
SockJS relative #470
use spring boot 2.0.2 websocket with contextPath not working good, need u help, thx.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 18, 2019
@wilkinsona
Copy link
Member

Thanks for the report. Unfortunately, “not working good” does not give us enough information to diagnose the problem. The SockJS client issue that you opened didn’t make things much clearer. If you would like us to spend some time trying to help you please spend some time to make it easier for us to do so. You can make it easier by describing the problem in detail and by providing a minimal sample (as a zip attached to this isssue or in a separate Git repository) that reproduces the problem.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Feb 18, 2019
@xzzh999
Copy link
Author

xzzh999 commented Feb 19, 2019

@wilkinsona
Thank you for your reply, there is the test demo(client and server projects), but i don't think it's the project code's problem because the websocket part's code is very simple. I just add server.servlet.contextPath=/MyServer, before i add this, the websocket is fast enough to make connection, but after add this, the connection made is so slow or even failed, and i have already add the CORS code to avoid 404 errors.

And in web client side, i use webpack and vue.js, and use proxytable with baseurl added.

module.exports = {
    base_url_name: base_url_name,

    dev: {
        // Paths
        assetsSubDirectory: 'static',
        assetsPublicPath: base_url,
        proxyTable: {
            '/': {
                 target: 'http://80.0.0.198:8082',
                 changeOrigin: true,
                // pathRewrite: {
                //     '^/': ''
                // }
            },
            '/ws/*': {
                 target: 'ws://80.0.0.198:8082',
                 ws: true
            }
        },

        // Various Dev Server settings
        host: IPAdress, // can be overwritten by process.env.HOST
        port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
        autoOpenBrowser: false,
        errorOverlay: true,
        notifyOnErrors: true,
        poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
...
}

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 19, 2019
@wilkinsona
Copy link
Member

Thanks for the extra information. Can you please explain why you believe the problem is caused by Spring Boot? From your description, where you say the connection sometimes works slowly and sometimes fails, it sounds like a network problem. How does it behave without any proxy configuration?

@wilkinsona wilkinsona added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Feb 19, 2019
@xzzh999
Copy link
Author

xzzh999 commented Feb 20, 2019

@wilkinsona
That is the reason! When i not use proxy table, just build the front end package, and run spring boot server independent, it works ok! When i use proxy to debug, the problem comes!(too slow) Here is the print:

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 20, 2019
@wilkinsona
Copy link
Member

Thanks for trying things without the proxy. Given that things work well without it, I think it's reasonable to assume that the proxy is causing the problem. That's something that is out of Spring Boot's control so I am going to close this issue. The incompatible SockJS errors look suspicious to me. My understanding is that proxyTable is backed by webpack-dev-server. Searching its issue tracker shows others have had similar problems with SockJS. webpack/webpack-dev-server#474 is one example.

@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Feb 20, 2019
@xzzh999
Copy link
Author

xzzh999 commented Feb 21, 2019

@wilkinsona
Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants