LoginSignup
1
1

More than 5 years have passed since last update.

Swift3 / Alamofire4 利用時に、__tcp_connection_write_eof_block_invoke Write close エラーがでて、Responseが読めない

Posted at
Alamofire.request(url, method: .get, parameters: ["key": "value"], encoding: JSONEncoding.default, headers: nil)
   .responseJSON(completionHandler: { response in

として実装していたところ、長時間応答待ち状態になり、
最終的に
__tcp_connection_write_eof_block_invoke Write
というエラーが発生し、JSONが読めないという問題に遭遇しました。

いくつか調べているとiOS10での問題だとか、iPhoneのSocket実装の問題だからAlamofireの問題じゃないよ、という回答がいくつか見つかったのですが、解決策がなかったので、少し手間取っていました。

根本的に原因が追いきれていないので、完全な解決策ではないのですが、

// url を https://www.hogehoge.com/apiから
// https://www.hogehoge.com/api?key=valueに変更
Alamofire.request(url, method: .get, parameters: nil, encoding: JSONEncoding.default, headers: nil)
   .responseJSON(completionHandler: { response in

とすることで問題が解決しました。
もし原因をご存知の方がいらっしゃったらコメントください。

悩んでらっしゃる方、一度お試しください。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1