increase request timeout

- give more time for requests to complete
- change mailserver everytime a request time out

Signed-off-by: yenda <eric@status.im>
This commit is contained in:
yenda 2018-10-15 21:32:58 +02:00
parent 647db6d698
commit d09a2956c3
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
1 changed files with 6 additions and 4 deletions

View File

@ -28,11 +28,12 @@
(def one-day (* 24 3600)) (def one-day (* 24 3600))
(def seven-days (* 7 one-day)) (def seven-days (* 7 one-day))
(def maximum-number-of-attemps 3) (def maximum-number-of-attemps 2)
(def request-timeout 30)
(def connection-timeout (def connection-timeout
"Time after which mailserver connection is considered to have failed" "Time after which mailserver connection is considered to have failed"
5000) 10000)
(defn- parse-json (defn- parse-json
;; NOTE(dmitryn) Expects JSON response like: ;; NOTE(dmitryn) Expects JSON response like:
@ -178,6 +179,7 @@
(clj->js {:topic topic (clj->js {:topic topic
:mailServerPeer address :mailServerPeer address
:symKeyID sym-key-id :symKeyID sym-key-id
:timeout request-timeout
:from from :from from
:to to}) :to to})
(fn [error request-id] (fn [error request-id]
@ -370,8 +372,8 @@
(fx/defn resend-request (fx/defn resend-request
[{:keys [db] :as cofx} {:keys [request-id]}] [{:keys [db] :as cofx} {:keys [request-id]}]
(if (>= maximum-number-of-attemps (if (<= maximum-number-of-attemps
(get-in [:transport.inbox/current-request :attemps] db)) (get-in db [:transport.inbox/current-request :attemps]))
(fx/merge cofx (fx/merge cofx
{:db (update db :transport.inbox/current-request dissoc :attemps)} {:db (update db :transport.inbox/current-request dissoc :attemps)}
(change-mailserver)) (change-mailserver))