| DOWNLOADER_EVT_ERROR | An error has occurred during download and the connection to the server has been lost.
Error reason may be one of the following:
- -ECONNRESET: Socket error, peer closed connection.
- -ECONNREFUSED: Socket error, connection refused by server, or (CoAP) the server returned an error response (e.g. 4.01 Unauthorized).
- -ECONNABORTED: (CoAP) reconnect attempts exhausted, download aborted.
- -ENETDOWN: Socket error, network down.
- -ETIMEDOUT: Socket error, connection timed out.
- -EHOSTDOWN: Host went down during download.
- -EBADMSG: HTTP response header not as expected.
- -ERANGE: HTTP response does not support range requests.
- -E2BIG: HTTP response header could not fit in buffer.
- -EPROTONOSUPPORT: Protocol is not supported.
- -EINVAL: Invalid configuration.
- -EAFNOSUPPORT: Unsupported address family (IPv4/IPv6).
- -EHOSTUNREACH: Failed to resolve the target address.
- -EMSGSIZE: TLS packet is larger than the nRF91 Modem can handle.
- -EMLINK: Maximum number of redirects reached.
How the downloader reacts depends on the error:
-ECONNRESET: the downloader automatically closes the connection, reconnects, and resumes the download without invoking the callback. The DOWNLOADER_EVT_ERROR event is only generated if the reconnection itself fails.
- Any other error (including the CoAP
-ECONNREFUSED and -ECONNABORTED above): the DOWNLOADER_EVT_ERROR event is generated. Return a non-zero value from the callback to stop the download, or zero to let the downloader reconnect and resume.
In case the download is stopped or completed, and the downloader_host_cfg.keep_connection flag is set, the downloader will stay connected to the server. If a new download is initiated towards a different server, the current connection is closed and the downloader will connect to the new server. The connection can be closed by deinitializing the downloader, which will also free its resources.
If the downloader_host_cfg.keep_connection flag is not set, the downloader will automatically close the connection. The application should wait for the DOWNLOADER_EVT_STOPPED event before attempting another download.
|