shuoshadow edited a comment on issue #495:
URL: 
https://github.com/apache/apisix-ingress-controller/issues/495#issuecomment-848507043


   > @shuoshadow How did you send requests? Please give us a minimal 
reproducible case.
   
   frontend:
   ```javascript
   const initSocket = () => {
       const socketURI = 
`${WEBSOCKET_URL_OBJ[props.namespace]}/api/v1/pod/exec/${props.namespace}/${props.podName}`
   
       socketRef.current = new WebSocket(socketURI)
       socketOnClose()
       socketOnOpen()
       socketOnError()
     }
   
     const socketOnClose = () => {
       socketRef.current.onclose = () => {
         socketRef.current.close()
         termRef.current.write('connet is closed!!!')
         console.log('close socket')
       }
     }
   
     const socketOnOpen = () => {
       socketRef.current.onopen = () => {
         initTerm()
       }
     }
   ```
   
   backend:
   
        logger.Debug("in ExecPod")
        if !ctx.IsWebsocket() {
                ctx.JSON(http.StatusUnsupportedMediaType, 
hr.ErrResponse{hr.ErrorData{hr.ErrorCodePodExecError, "===not websocket 
request==="}})
                return
        }
   
   
![image](https://user-images.githubusercontent.com/10016360/119616001-ad4bcb80-be32-11eb-8dc3-2e2fab0819a5.png)
   
   415 code was return by backend, !ctx.IsWebsocket() 
   ```golang
   func (c *Context) IsWebsocket() bool {
        if strings.Contains(strings.ToLower(c.requestHeader("Connection")), 
"upgrade") &&
                strings.EqualFold(c.requestHeader("Upgrade"), "websocket") {
                return true
        }
        return false
   }
   ```
   
   it works right by nginx-ingress


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to