Comments (9)
Thanks for reporting @simpers. Let me know if you get any more errors. I'll look into this and see what else I can find.
from swiftphoenixclient.
@dsrees I have a few ideas of what's up.
Either the server is misconfigured, but I do not know what that would be as I have left it all at the defaults (I think) and just implemented 3 channels, currently.
Or there is an iOS-thing that causes this to happen because of a behaviour that is happening inside SwiftPhoenixClient, as I keep getting some weird behaviour regarding the sockets themselves, where I sometimes get errors from the TCP layer suggesting something is wrong on that layer.
Or it is an error with the implementation of the Phoenix Client. I did however also try another client called Birdsong, and it also behaves in this same way, albeit has less debugging information so if I'd use that I would only have a 'disconnected' message, if even that.
So I am wondering if it is the server or not. Which Phoenix version do you support? Is there a way to change the channel protocol from 1.0 upward? I read something about Phoenix having a WebsocketSerializer which you can decide to support a minimum version of, or something.
Which Erlang/OTP version is necessary for all of this to work? If you have any data on this yourself I'd love to hear some. I'll try to create a minimal app example doing the same thing (it just shows events in a ViewController currently) to see if it occurs there as well, or if it is a project specific problem of my iOS app.
from swiftphoenixclient.
@simpers Thanks for all of that! My initial thought is that it is server side. The Socket is closing with a 1000 code which means it was closed successfully. However that could also be the case if the client requested it be closed.
The client should be reattempting a connection if it was closed due to an error. It won't attempt to reconnect if the client or the server closed the connection (at least, that's how it is supposed to work. There may be a bug) Because you're not getting re-connect attempts, my thought is that something is going on here.
If you could, try spinning up the demo server and point your app to that and see if you're still getting disconnects.
The client is built to work with the latest phoenix version. There currently is not a way to change the configuration to work with different versions of Phoenix.
from swiftphoenixclient.
@dsrees I think it might have been this:
timeout: 30_000
I guess depending on the exact timing of this timeout, seeing as the heartbeat also seems to be 30 seconds, that might have caused the random
disconnects.
I think I copied all of this when I tried to solve the check_origin: false in order to allow connections from the iPad earlier.
transport :websocket Phoenix.Transports.Websocket,
timeout: 30_000,
serializer: [ { Phoenix.Transports.WebSocketSerializer, "~> 1.0.0" } ],
check_origin: false
I have removed it to see if it helps and it looks promising. However, is there no way to change the default heartbeat timer of the client?
But how come it is registered as an error? I tried to implement some reconnection logic due to all of this, seeing as it didn't automatically do that even though I set it to (which you answered by saying it doesn't because it's a normal close of the socket), but it fails the reconnect with an actual error. Do I need to create an entirely new socket or something after a successful closure of the socket?
I also wonder what that serializer is for, which is what I referred to in my previous comment I think.
from swiftphoenixclient.
Good find! You can change the heartbeat interval
let socket = Socket()
socket.heartbeatIntervalMs = 20000 // 20s heartbeat
You can also disable it
socket.skipHeartbeat = true
See more here
I'll have to look into the reconnect logic. There may be something out of place
from swiftphoenixclient.
I'll experiment a bit locally with that setting then.
I guess what really confused me and got me pulling my hair was that it was logged as an error and indicated that something was broken, when it in fact as you say was behaving correctly. The only weird thing was that it was recorded as an error so I tried to fix it somehow and started looking in the wrong place.
from swiftphoenixclient.
@simpers - any result on this? I'm seeing similar issues (#122), but only on our staging server... Were you able to resolve it on your end?
from swiftphoenixclient.
@astjohn The error was that a misconfiguration on the server (timeout was set to 30 seconds, and the heartbeat was exactly 30 seconds as well, so sometimes it failed, sometimes not) resulted in an error on the client. So I thought something else was wrong, but I think we came to the conclusion that it behaved correctly. I just bumped the 30 seconds to something higher and it has worked after that.
from swiftphoenixclient.
@astjohn @simpers Glad you were both able to resolve this by adjusting the server timeout.
from swiftphoenixclient.
Related Issues (20)
- race condition in close/join events with v1 serialiser HOT 3
- 2.2.0 doesn't call receive callbacks HOT 2
- Move out additional Rx and Starscream solutions to separate Swift Packages HOT 9
- Question: Behaviour when remote kills connection. HOT 3
- How to configure heartbeat? HOT 4
- Problems with connections closing and not re-establishing HOT 4
- Access raw message data HOT 2
- Crash on channel connection HOT 1
- `Channel` `bindingsDel` array is not thread safe and appears to rarely cause a crash HOT 1
- Problems with connections on WatchOS 9 HOT 4
- Question: How do I know a socket was successfully opened? `isConnected` seems to say whether or not the handshake took place, not whether the socket was actually opened. HOT 13
- Error: "Undefined symbol: _$s18SwiftPhoenixClient7ChannelCMn" HOT 11
- SSL Pinning support after StarScream removal HOT 3
- Crash in `Channel.swift` `off()` function HOT 2
- Crash in `Socket.append<T>(callback:to:)` function HOT 5
- Automatic success for `Channel.leave()` attempts when offline HOT 3
- Sending binary data in a message HOT 3
- Crash on Channel initialization HOT 4
- Version 5.3.1 is unavailable via cocoapods HOT 1
- Adding a certificate authentication request HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftphoenixclient.