Comments (21)
@cedb777 @cleverClosure
I also can not to send headers through connectionHeaders, but I send it in request, like this
var socketRequest: NSURLRequest {
let webSocket = URL(string: urlString)!
var request = URLRequest(url: webSocket)
request.setValue(("Bearer " + token).toBase64, forHTTPHeaderField: "Authorization")
return request as NSURLRequest
}
from stompclientlib.
It worked for me with this code:
` let url = URL(string: "wss://(defaultSocketBase)/push?access_token=(token)")!
let request = NSURLRequest(url: url)
let headers: [String: String] = ["heart-beat": "20,20"]
socketClient.openSocketWithURLRequest(request: request, delegate: self, connectionHeaders: headers)`
from stompclientlib.
@cedb777 @cleverClosure
I also can not to send headers through connectionHeaders, but I send it in request, like thisvar socketRequest: NSURLRequest { let webSocket = URL(string: urlString)! var request = URLRequest(url: webSocket) request.setValue(("Bearer " + token).toBase64, forHTTPHeaderField: "Authorization") return request as NSURLRequest }
For the ones who could not make it using headers on connection, try this, that approach works on my environment.
from stompclientlib.
Hello @cleverClosure ,
I need an example to test it out. Can you provide it?
from stompclientlib.
Can I send it to you privately somehow? I don't want the url to be public
from stompclientlib.
You can send me an email : [email protected]
from stompclientlib.
I've sent you an email
from stompclientlib.
Hello again @cleverClosure,
As I mentioned on the mail, I got this error from your server:
didFailWithError: Optional(Error Domain=SRWebSocketErrorDomain Code=2133 "Invalid Sec-WebSocket-Accept response" UserInfo={NSLocalizedDescription=Invalid Sec-WebSocket-Accept response})
Can you provide a working authentication token or please check your server part :)
from stompclientlib.
Yes, that is exactly what I get when I use ws instead of wss or https. Here is the new token: 451ac7a5-ad93-4859-8c62-b41e96d6a34d
from stompclientlib.
The server side works, because I am able to connect to it from the web client
from stompclientlib.
@cleverClosure
Have you checked these issues?
#30 and #32 ?
from stompclientlib.
The webserver works on sockJS but adding /websocket to the url didn't help
from stompclientlib.
@cleverClosure I'm really sorry but I could not find the problem about your issue :(
I've tried another websocket with authentication and it works without any issue. I have only left is that your websocket backend might have an issue about it.
from stompclientlib.
Can I ask you which websocket with auth did you try (the one you were able to connect successfully)? Is that local webserver or something?
from stompclientlib.
I've tried on a very simple local webserver. Unfortunately, I do not have any other options.
from stompclientlib.
Someone solved this problem?
I have the same issue.
from stompclientlib.
Same issue! Someone solved this ?
from stompclientlib.
@said13 and @cedb777, Can you guys provide me with an example of the issue? Because I could not reproduce it on my own simple WebSocket server.
from stompclientlib.
@iOSDias Hi! It works?
from stompclientlib.
@said13 yes
from stompclientlib.
Finally, I closed the issue :) Please open a new one if you still have a problem.
from stompclientlib.
Related Issues (20)
- Subscribe response HOT 3
- How can I access http response header (handshakeResponseHeaders) about handshaking? HOT 1
- Disconnecting after using autoReconnect HOT 15
- Add openSocketWithURLRequest connectionheader to websocket urlRequest's HTTPHeaderField and request additional connect function. HOT 4
- Cannot connect to socket HOT 3
- Error Domain=SRWebSocketErrorDomain Code=2132 "received bad response code from server 403" HOT 4
- Add method/flag to stop logging HOT 6
- Subscribe Issue HOT 3
- Version 2.0 HOT 12
- Received bad response code from server 403 HOT 4
- Error Domain=SRWebSocketErrorDomain Code=2132 "received bad response code from server 403" HOT 3
- Socket Disconnect after 30 min HOT 5
- misprint in code HOT 3
- Support for WatchOS HOT 2
- Swift Package Manager support? HOT 2
- Connection variable is not set to false when WebSocket receives DISCONNECT HOT 1
- Auto disconnection with error code 4500 HOT 2
- Facing Issue while sending the message HOT 1
- Privacy Manifest HOT 6
- Adding response after sent to server or not HOT 7
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 stompclientlib.