vSphere

 View Only
  • 1.  Remote Plugin Sample WebSocket not working with Spring 2.1 / Spring 3

    Posted Mar 28, 2024 11:47 PM

    Hello,

    I'm trying to develop a Remove Plugin for vCenter, and found that the WebSocket was not correctly working (when proxied through vCenter).

    I tried to replicate with the sample project (from vSphere-client-sdk-802.zip) and found that the project was using Spring Boot 2.0.3.
    As soon as I update the dependency to 2.1.X, the WebSocket stops working.

    Then, I debugged the Java program and found that Tomcat updated the way they validate one header used during the WebSocket handshake (66548 – Tomcat does not validate value of Sec-Websocket-Key header (apache.org)).

    The vCenter proxy is not setting the header "Sec-Websocket-Key" to a valid value (it sets to "ZW52b3k=", "envoy" in Base64).

    Also, I know there is a "bug" in the sample, a missing encodeURIComponent, and I already fixed it during my tests.

    My questions is, does someone have a workaround or solution?

    I tried changing the value with an interceptor but this just completely break the WebSocket connection as the value is used later.

    Tomorrow, I will try to find a version of Spring 3 not using an updated Tomcat version or force a version without the patch but this is not ideal for future projects.

     

    Example of a WebSocket UPGRADE request with the incorrect header:

     



  • 2.  RE: Remote Plugin Sample WebSocket not working with Spring 2.1 / Spring 3

    Posted Mar 29, 2024 03:59 PM

    The last Tomcat version without the validation is 10.1.7 but is not fully compatible with Spring 3.2.3.

    However, forcing the version of the Tomcat WebSocket component is working:

    implementation 'org.apache.tomcat.embed:tomcat-embed-websocket:10.1.7'

     



  • 3.  RE: Remote Plugin Sample WebSocket not working with Spring 2.1 / Spring 3

    Broadcom Employee
    Posted Apr 03, 2024 04:51 AM

    Hi  ,

     

    Thanks for discovering the issue and proactively providing help to other forum users.

    The issue with WebSockets is already addressed in the Remote Plugin Sample and will be available as part of the next vSphere Client SDK release.

     

    Best Regards,

    Denis