Cloud Development Kit

WebSocket network error: WebSocket proxy authentication couldn't be handled.

We used Math of CDK.

And I used iPad device.

<iPad information>

- iPad Air2

- iOS 10.3.2

- Browser : Safari


Under the network with proxy server, we faced the attached error and couldn't use your MyScript library.

image


If we use the proxy, can't we use your library?
At least, under the network without proxy, this issue was not happened.


Hi Masashi Takahashi,

What your are describing is a proxy error. Please not that MyScript use wss (secure websocket).

Could you use this webpage from the device not working http://demos.kaazing.com/echo/ ? Please replace ws:// with wss:// and test again.

If you face the same error this is a confirmation that a proxy is causing the error.

Best regards

Pierre-Alban DEWITTE

Dear Mr. Pierre-Alban DEWITTE

Thank you so much for your reply.

 > Please not that MyScript use wss (secure websocket).

For the above your answer, shouldn't I use wss (secure websocket)?

The below is a piece of my source code.

Are there any wrong?


    MyScript.register(editorElement, {
        recognitionParams: {
            type: 'MATH',
            protocol: 'WEBSOCKET',
            apiVersion: 'V4',
            server: {
                scheme: 'https',
                host: 'webdemoapi.myscript.com',
                applicationKey: 'my applicationKey',
                hmacKey: 'my hmacKey'
            },
            v4: {
                math: {
                    mimeTypes: ['application/x-latex']
                }
            }
        }
    }

 

Also, I will try your suggestion in your commented site.


Dear Masashi Takahashi,

You are right regarding the scheme parameter. https is converted to wss when protocol is WEBSOCKET.

This should have no impact on your problem but if you intent to build a production application please use cloud.myscript.com as host. webdemoapi.myscript.com is for demo and evaluation purpose only (you will be charge the same way but cloud.myscript.com is the host where we guaranty high availability) 

Best regards

Pierre-Alban DEWITTE

Dear Mr. Pierre-Alban DEWITTE


> Could you use this webpage from the device not working http://demos.kaazing.com/echo/ ? Please replace ws:// with wss:// and test again.

> If you face the same error this is a confirmation that a proxy is causing the error.


We confirmed the above, but in the both case of ws:// and wss://, we could use "connect", "send", "close" on the device with proxy network.

(This network is the one which had proxy error in the previous day. )


Do you have another reason for it?

Or Can we confirm other check?


Masashi Takahashi.

Hi ,

We have "Handshake failed due to invalid Upgrade header" in our logs. We had a customer facing the same issue and it was cause by a reverse proxy configuration.

Here is a stackoverflow giving a way to solve this problem.

https://stackoverflow.com/questions/31211919/spring-websocket-handshake-failed-due-to-invalid-upgrade-header-null


Best regards

Pierre-Alban DEWITTE


Dear Pierre-Alban DEWITTE


Thank you so much for your reply.

Sorry for my lower understanding for Web socket.
You say that the reverse proxy setting of user's network cause this issue. Is it right?

Or, is it the setting of system's web server/javascript coding?
We use the company's proxy, so change this setting is not easy, I suppose.
If the reverse proxy setting can't be changed, then is it difficult to continue to use your application?


Best regards.

Masashi Takahashi.

Dear Masashi Takahashi,

Your understanding is right. I am pretty sure that the problem is coming from your company proxy. I could not say much about the difficulty of changing the setting but we can not do anything on our side. The only way to use our API is to use the REST (V3) mode. Of course you will not benefit from interactivity which comes with V4 but it could be enough depending of your use case.  Stay tune the REST V4 should land in the upcoming quarter.

Another way to solve this problem is to go native. We get you covered their too.

Best regards

Pierre-Alban DEWITTE



Dear Mr. Pierre-Alban DEWITTE

We discussed about company proxy, but it can't be changed.

If the proxy error is happened, then I'd like to show the error message due to proxy error.


The below is our source code for calling your product.

I suppose that I can get the message from "console.log(this.editor.error.text());".


I have 2 question.

- If the proxy error is happened, then can I get the message which I can understand the proxy error from this variable?

- How can I understand that the proxy cause this error? If the proxy error is happened, then is the fixed message set?


$(document).ready(function () {
    var editorElement = document.getElementById('math-input');
    MyScript.register(editorElement, {
        recognitionParams: {
            type: 'MATH',
            protocol: 'WEBSOCKET',
            apiVersion: 'V4',
            server: {
                scheme: 'https',
                host: 'cloud.myscript.com',
                applicationKey: 'API_KEY',
                hmacKey: 'H_KEY'
            },
            v4: {
                math: {
                    mimeTypes: ['application/x-latex']
                }
            }
        }
    },
    {color: '#1a9fff'});

    editorElement.addEventListener('exported', function (event) {
        handleExportedEvent(this, event);
    });
    // Handle error
    editorElement.addEventListener('error', function (event) {
        console.log(event);
        console.log(this.editor.error.text());
    });

});

Dear Masashi Takahashi,

Your implementation seems good. As we could not reproduce the issue on our side we could not assure you that il will work but this looks like the good way to manage the problem.

Best regards

Dear Mr.Pierre-Alban DEWITTE

 

Thank you so much for your answer.

 

1) Currently, do you know what message in the "this.editor.error.text()" is set when the proxy error is happened?

 

2) Is the message in the "this.editor.error.text()" always same? Or, is it different by browser?

 

Best regards.

Masashi Takahashi.

 

 


Dear Masashi Takahashi,

Please consider checking the console for the error message and not using "this.editor.error" as this is only the error div we use to display the error message (e.g. wrong application key).

The error message you will find in the console is not always the same. It depends on the kind of error type. Some are managed on our side, some are managed by the browser (for example, if the connection to the WebSocket isn't working, the browser will display an error). We don't have any specific message for a proxy error as this will be managed by the browser.


Best regards,

Romain.

 

Login or Signup to post a comment