Can't have a timeout of over 2 minutes with this.http.get?

蹲街弑〆低调 提交于 2019-11-29 12:22:39

You can not change the web browser's network timeout setting for HTTP requests. The timeout() operator throws a JavaScript error when the timer is reached, but this has nothing to do with the network timeout for communications.

For example; I can use the timeout() operator on any observable.

of("hello").pipe(delay(5000), timeout(1000));

The above will timeout after 1 second.

My angular 4.3.2 code is calling my back-end service that takes 2-4 minutes to return

The server must transmit a HTTP header and a partial body during the duration of 2-4 minutes. This is required to continue the HTTP connection, and there is nothing the client can do to keep the connection alive.

It is a bad practice for a HTTP request to not complete quickly.

You can either ask the server to start a task, and then poll on an interval to see if the task is complete, or you can use websockets to communicate with the server and remain connected until it is complete.

Both approaches are broad topics and I can't go into more details than that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!