Catch ActionCable Connection Refused - ruby-on-rails

I've looked all around and can't find an answer to this issue. How do I catch something like the following error in javascript?
WebSocket connection to 'ws://clean.lvh.me:3000/cable' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
Is there a way for me to test if the connection is active?

I wasn't quite able to catch any errors around the ActionCable websocket connection, but I did figure out how to test if the connection is active using the data from the ActionCable object:
App.rooms.consumer.connection.disconnected
The value is false when connected and true when disconnected.

Related

what causes XPC error Connection interrupted

I have piece of code that fires couple of requests using NSURLsession and sometimes I get the below message on debugger of xcode
received XPC error Connection interrupted for message type 3
kCFNetworkAgentXPCMessageTypePACQuery
I am thinking what causes this issue ?
Is it something to be worried about ?
Googling doesn't help much
Maybe it is caused by Network Proxy like VPN/VPS ,close them and Command R again.
I got exactly the same error.
During the first attempt I had the VPN on. After turning it off the message did not appear.

Why do I get a "handshake failed" error in my Xcode console?

2015-08-01 22:30:43.893 MyApp[2425:284133] ERROR: handshake failed ... The request timed out.
2015-08-01 22:30:43.896 MyApp[2425:284133] ERROR: handshake failed ... The request timed out.
2015-08-01 22:30:43.899 MyApp[2425:284133] ERROR: handshake failed ... The request timed out.
2015-08-01 22:30:43.912 MyApp[2425:284133] ERROR: handshake failed ... The request timed out.
2015-08-01 22:30:43.913 MyApp[2425:284133] ERROR: handshake failed ... The request timed out.
2015-08-01 22:30:43.913 MyApp[2425:284133] ERROR: handshake failed ... The request timed out.
2015-08-01 22:30:43.914 MyApp[2425:284133] ERROR: handshake failed ... The request timed out.
2015-08-01 22:30:43.914 MyApp[2425:284133] ERROR: handshake failed ... The request timed out.
2015-08-01 22:30:43.915 MyApp[2425:284133] ERROR: handshake failed ... The request timed out.
2015-08-01 22:30:43.915 MyApp[2425:284133] ERROR: handshake failed ... The request timed out.
I've been getting this at random times. How can I check exactly which framework/library is causing this? It just prints in my Xcode console.
Look hat this Question it seems to be very similar, are you using a library which using a websocket server. Maybe this can solve your Problem very fast. If not please Post a list of librarys you use and form you code where you set up a socket.
Timeouts occur if an api does not respond for a long time, which is usually set to 15, 30 or 60 seconds.
Your timestamps are split across a second as well, which clearly says that you are using a socket connection and probably a library for the same, which is the issue here. Check the library you are using. It will be a server side issue.
Some libraries in your project might use socket or SSL authentication.
In my case, I saw same error message, handshake failed, when I tried to send push notification to APNS server with wrong certificates.
It's hard to find which library or framework print out to the console.
Try to remove 3rd party libraries included in the project until the error message stops appearing.
I think you are running a websocket server for your project. You have to run a socket.io server. That's why xcode is showing this error.
See this similiar post on stackoverflow
My Socket.io on IOS fails to handshake with the websocket server
Some times when you use the push notification api sometimes the handshake failed error occurs , so read this apple documentation for trouble shooting if your push notification feature is logging this error App push notification troubleshooting
The way I can introduce may be not a good solution for you. And my answer works based on these two conditions
1.you have to comment nearlly all the "println" in your code
2.the instance call "println" to send error message
Then, you can set "Symbolic breakpoint" in "Debug menu -> Breakpoints -> Create Symbolic Breakpoint", and set condition to be "println"
(If the module is old, you may have to break at "NSLog" or some thing)
reference to how to set symbolic breakpoint: http://rshankar.com/debugging-swift-app-in-xcode/

issue with Afnetworking 1.0 error handling

I am using AfNetworking 1.0 into my app.I have created a singleton class of AFHTTP Client.
So all the API's are place in the same class.
I am getting a very wierd issue.
For eg: Let say, i have requested for some data from server.But the internet connection has lost.
So the failure block get's called.
m getting the following error:
Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo=0x797dcc70 {NSErrorFailingURLStringKey=https://testing.com?searchText=s&pageSize=10&pageNumber=5, _kCFStreamErrorCodeKey=57, NSErrorFailingURLKey=https://testing.com?searchText=s&pageSize=10&pageNumber=5, NSLocalizedDescription=The Internet connection appears to be offline., _kCFStreamErrorDomainKey=1, NSUnderlyingError=0x7aa367e0 "The Internet connection appears to be offline."}
But if i try to get the status code using following code:
NSLog(#"Status code %d",[operation.response statusCode]);
m getting Status Code as "0".
Can you please explain,why i am getting Status code as "0"?
I have to handle the error,depends on HTTP Status Code.So what is the best way to get this done?
(the same way which i am doing or is there any other way.)
In this case you can't use the status code because there isn't one. The status code comes from the server and in this case the client has not been able to contact the server.
You should use the error domain and code to handle this case.

iOS WebSocket not connecting to Server using SocketRocket

I'm creating a chat application whose WebSocket server is written in java.
For WebSocket client i'm using SocketRocket library.
Everything works fine when i try to connect from localhost or 127.0.0.1.
But when i try to connect it using the public IP, it gives following error in - (void) webSocket:(SRWebSocket *)_webSocket didFailWithError:(NSError *)error method:
Error Domain=NSPOSIXErrorDomain Code=57 "The operation couldn’t be completed. Socket is not connected"
Here is how i initialize the SRWebSocket object:
webSocket = [[SRWebSocket alloc] initWithURL:[NSURL URLWithString:#"ws://IP_ADDRESS:8080/ChatWebSocket/chat/12345"]];
// connects successfully when IP_ADDRESS = localhost or 127.0.0.1
// gives 'Socket is not connected' error when IP_ADDRESS = some public IP address
I've also tried initializing SRWebSocket with initWithURLRequest:.
P.S i've also tested and verified that the WebSocket server is accessible by its public IP address from a javascript code.
Therefor i think the issue is at the client end.
Any help will be appreciated.
Thanks in advance
After almost 2 days of research, i finally realized that the problem was arising on simulator only.
When i tested the same code on an iPod touch, it worked like a charm! :)

Socket.io chat example handshake failed from iOS

I'm trying to create a native iOS client for the chat example in Socket.io.
I've set up everything, but at this point...
[socketIO connectToHost:#"localhost" onPort:3000];
I get this error
ERROR: handshake failed ... Server returned status code 400
I guess I have to send some params, maybe like this...
[socketIO connectToHost:#"localhost" onPort:3000 withParams:...];
...but I have no idea what I have to send.
Thanks!

Resources