URLSessionWebSocketTask sometimes only connects after some retries - swift

I don't have a consistent reproduction path. I am creating a plain URLSessionWebSocketTask and try to connect to my server running on localhost.
Sometimes it won't connect instant, but after a few tries it succeed. I don't get any connecting logging on the server side when the error loggings appear in the app.
These are the logs:
[tcp] tcp_input [C9.1.1:2] flags=[R.] seq=0, ack=2805414308, win=0 state=SYN_SENT rcv_nxt=0, snd_una=2805414307
[tcp] tcp_input [C9.1.1:2] flags=[R.] seq=0, ack=2805414308, win=0 state=SYN_SENT rcv_nxt=0, snd_una=2805414307
Connection 9: received failure notification
Connection 9: failed to connect 1:61, reason -1
Connection 9: encountered error(1:61)
Task <F324C4E7-092F-479B-98C2-5FFE835A8C6A>.<10> HTTP load failed, 0/0 bytes (error code: -1004 [1:61])
Task <F324C4E7-092F-479B-98C2-5FFE835A8C6A>.<10> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSErrorFailingURLStringKey=http://mac-studio.local:3012/, NSErrorFailingURLKey=http://mac-studio.local:3012/, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalWebSocketTask <F324C4E7-092F-479B-98C2-5FFE835A8C6A>.<10>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <F324C4E7-092F-479B-98C2-5FFE835A8C6A>.<10>, NSLocalizedDescription=Could not connect to the server.}
[tcp] tcp_input [C10.1.1:2] flags=[R.] seq=0, ack=836765050, win=0 state=SYN_SENT rcv_nxt=0, snd_una=836765049
[tcp] tcp_input [C10.1.1:2] flags=[R.] seq=0, ack=836765050, win=0 state=SYN_SENT rcv_nxt=0, snd_una=836765049
It retries every second to connect. After the 10th attempt or so, it is connected and remains connected without any problems. Sometimes I do not have any problem and it connect instant.
Is there any property I can use to make sure it will try to connect somewhat longer?

Related

What is causing this Flutter Firestore error on macOS?

I'm trying to create a simple document in my Firestore database when a user presses submit. It works when the app is run on iOS but this is what I see when I run it on macOS:
2022-03-20 19:39:47.333823-0700 globe_artist[62624:775059] Connection 12: received failure notification
2022-03-20 19:39:47.333872-0700 globe_artist[62624:775059] Connection 12: failed to connect 1:1, reason -1
2022-03-20 19:39:47.333901-0700 globe_artist[62624:775059] Connection 12: encountered error(1:1)
2022-03-20 19:39:47.337548-0700 globe_artist[62624:775059] Task <3286828D-3FE8-44EB-9E85-C164E1B00836>.<1> HTTP load failed, 0/0 bytes (error code: 1 [1:1])
2022-03-20 19:39:47.338184-0700 globe_artist[62624:775059] Task <3286828D-3FE8-44EB-9E85-C164E1B00836>.<1> finished with error [1] Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" UserInfo={_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <3286828D-3FE8-44EB-9E85-C164E1B00836>.<1>, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=1, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <3286828D-3FE8-44EB-9E85-C164E1B00836>.<1>"
), _NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0, ipv4, dns}
2022-03-20 19:40:19.959305-0700 globe_artist[62624:775842] [] nw_path_evaluator_create_flow_inner NECP_CLIENT_ACTION_ADD_FLOW A50B5D10-DA1B-457F-9F74-3EAC1A8BA7A6 [1: Operation not permitted]
2022-03-20 19:40:19.959890-0700 globe_artist[62624:775842] [connection] nw_endpoint_flow_setup_channel [C13.1 142.250.217.106:443 in_progress channel-flow (satisfied (Path is satisfied), interface: en0, ipv4, dns)] failed to request add nexus flow

TIMEOUT WHILE CONNECTING TO SERVER

When I use Wi-Fi to upload code through VS Code, it shows the following error. But if I use mobile network, it works.
[error] Error: Timeout while connecting to server
at Timeout._onTimeout (c:\Users\faraz\.vscode\extensions\liximomo.sftp-1.12.9\dist\extension.js:70:109790)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)

Flutter integration tests, with FlutterFire, unable to connect when trying to run for Firebase Test Lab

I have a Flutter app (using version 2.5.1) that
Runs on a simulator
Run on a physical iOS device
Runs when I distribute it using TestFlight
Has integration tests, that run just fine on the simulator.
The app uses Flutterfire and the integration tests uses parts of the app that use Flutterfire.
However, when I follow these instructions in order to create something that can eventually be distributed to Firebase Test Lab, I stumble on the penultimate step:
xcodebuild test-without-building -xctestrun "build/ios_integ/Build/Products/Runner_iphoneos15.0-arm64-armv7.xctestrun" -destination id=<MYDEVICEID>
The app deploys to the physical device, and starts to run, but seems to fail to connect to any Firebase back-ends.
The logs have errors that look like those below.
Any pointers as to how I can fix this will be much appreciated!
Test Suite 'All tests' started at 2021-09-23 18:50:58.044
Test Suite 'RunnerTests.xctest' started at 2021-09-23 18:50:58.045
Test Suite 'RunnerTests' started at 2021-09-23 18:50:58.045
Test Case '-[RunnerTests testIntegrationTest]' started.
2021-09-23 18:50:58.047998+0100 Runner[404:7739] flutter: 00:00 +0: Porridge (setUpAll)
2021-09-23 18:50:58.049466+0100 Runner[404:7739] flutter: 00:00 +1: Porridge Create User
2021-09-23 18:50:58.052143+0100 Runner[404:7734] 8.6.0 - [Firebase/Analytics][I-ACS023007] Analytics v.8.6.0 started
2021-09-23 18:50:58.052457+0100 Runner[404:7734] 8.6.0 - [Firebase/Analytics][I-ACS023008] To disable debug logging set the following
application argument: -noFIRAnalyticsDebugEnabled
2021-09-23 18:50:58.062413+0100 Runner[404:7730] [connection] nw_socket_handle_socket_event [C1.1:2] Socket SO_ERROR [61: Connection r
efused]
2021-09-23 18:50:58.062759+0100 Runner[404:7730] [connection] nw_socket_handle_socket_event [C1.2:2] Socket SO_ERROR [61: Connection r
efused]
2021-09-23 18:50:58.063110+0100 Runner[404:7730] Connection 1: received failure notification
2021-09-23 18:50:58.063199+0100 Runner[404:7730] Connection 1: failed to connect 1:61, reason -1
2021-09-23 18:50:58.063314+0100 Runner[404:7730] Connection 1: encountered error(1:61)
2021-09-23 18:50:58.063936+0100 Runner[404:7730] Task <0B92B415-FE63-4467-8248-8FB5B411688A>.<1> HTTP load failed, 0/0 bytes (error co
de: -1004 [1:61])
2021-09-23 18:50:58.064589+0100 Runner[404:7730] Task <0B92B415-FE63-4467-8248-8FB5B411688A>.<1> finished with error [-1004] Error Dom
ain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x281c31890
{Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErr
orFailingURLSessionTaskErrorKey=LocalDataTask <0B92B415-FE63-4467-8248-8FB5B411688A>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <0B92B415-FE63-4467-8248-8FB5B411688A>.<1>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=http://localhost:9099/www.googleapis.com/identi
tytoolkit/v3/relyingparty/signupNewUser?key=AIzaSyCHkqtqAXDFllu7SmuwSw8_pudpAn-dzdM, NSErrorFailingURLKey=http://localhost:9099/www.go
ogleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=AIzaSyCHkqtqAXDFllu7SmuwSw8_pudpAn-dzdM, _kCFStreamErrorDomainKey=1}
2021-09-23 18:50:58.065318+0100 Runner[404:7739] flutter: [firebase_auth/network-request-failed] Network error (such as timeout, interrupted connection or unreachable host) has occurred.
2021-09-23 18:50:58.065511+0100 Runner[404:7739] flutter: #0 MethodChannelFirebaseAuth.createUserWithEmailAndPassword (package:firebase_auth_platform_interface/src/method_channel/method_channel_firebase_auth.dart:272)
...etc....

Connection Refused and Cannot connect to Controller Error

I am getting an error when i try to stop services
Failed to connect to the controller: The controller is not available at localhost:9990: java.net.ConnectException: WFLYPRT0053: Could not connect to http-remoting://localhost:9990. The connection failed: WFLYPRT0053: Could not connect to http-remoting://localhost:9990. The connection failed: Connection refused
when i try to start services, i get below error and need to restart the server multiple times to resolve it. need a solution to avoid errors during start and stop services. we use keycloack sercurity as well
2020-02-11 19:21:01,191 WARNING [com.lgc.dsl.admin.security.controllers.DSSecurity] (default task-12) Connect to localhost:8880 [localhost/IP] failed: Connection refused (Connection refused)
2020-02-11 19:21:09,462 WARN [org.kie.server.services.impl.controller.DefaultRestControllerImpl] (KieServer-ControllerConnect) Exception encountered while syncing with controller at http:localhost:port/dsbpm-console/rest/controller/server/dsbpm-kieserver error Error while sending PUT request to localhost:port/dsbpm-console/rest/controller/server/dsbpm-kieserver response code 405
Default kie server is not showing up in the server section
2020-02-11 19:21:01,191 WARNING [com.lgc.dsl.admin.security.controllers.DSSecurity] (default task-12) Connect to localhost:8880 [localhost/IP] failed: Connection refused (Connection refused)
2020-02-11 19:21:09,462 WARN [org.kie.server.services.impl.controller.DefaultRestControllerImpl] (KieServer-ControllerConnect) Exception encountered while syncing with controller at http:localhost:port/dsbpm-console/rest/controller/server/dsbpm-kieserver error Error while sending PUT request to localhost:port/dsbpm-console/rest/controller/server/dsbpm-kieserver response code 405
Check if you have 'dsbpm-console' for 'org.kie.server.controller' property, like as:

NSURLError: the network connection was lost

Can someone help me understanding and resolving this error I am getting when connecting to web service:
NSURLError is: Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."
NSErrorFailingURLStringKey=http://username:password#..org:443/zws/xmlrpc/restricted1/, NSErrorFailingURLKey=http://username:password#..org:443/zws/xmlrpc/restricted1/,
NSLocalizedDescription=The network connection was lost., NSUnderlyingError=0x5f2b300 "The network connection was lost.