I am passing authentication token parameter like below...
socket = SocketIOClient(socketURL: URL(string:"http://localhost:3001")!, config: [.log(true), .forcePolling(true),.connectParams(["Authorisation": kToken])])
But it always gives an error....
LOG SocketParser: Decoded packet as: SocketPacket {type: 2; data: [login_ack, {
message = "InValid Token";
result = "";
status = error;
}]; id: -1; placeholders: -1; nsp: /}
As I think that I am missing some thing to establish authenticated socket connection. So, please guide me where I am lacking.
I have resolved it by my self!
It was the issue from back end team. They were put some dependencies with the socket call back sender device information details which they are taking from the socket call backs. And the actual problem was ,all the devices and computers were providing their device details but iOS was not giving it from their end with their security protection.So,their validity condition were not satisfying for iOS socket call backs.
Backend team handled this situation by putting "Other" device type checking at their end.
Related
I have developed a Quarkus app with which I want to receive and process MQTT messages.
This also works so far.
My problem is that when the internet goes down at the MQTT broker and the app reconnects afterwards, the app reconnects to the broker but no messages are received. I think that the "subscribe" method is not called anymore.
How can I solve this problem?
Here is my Config:
mp.messaging.incoming.smarthome/electricity.connector=smallrye-mqtt
mp.messaging.incoming.smarthome/electricity.host=192.168.1.88
mp.messaging.incoming.smarthome/electricity.port=1883
mp.messaging.incoming.smarthome/electricity.reconnect-attempts=3000
mp.messaging.incoming.smarthome/electricity.reconnect-interval-seconds=10
mp.messaging.incoming.smarthome/electricity.qos=1
mp.messaging.incoming.smarthome/electricity.failure-strategy=ignore
Here is my Controller:
#Incoming("smarthome/electricity")
public void consume(byte[] raw) {
String price = new String(raw,StandardCharsets.UTF_8);
String[] parts = price.split(",");
String watt = parts[0].trim();
String timeStamp = parts[1].trim();
byte wattH = Byte.parseByte(watt.replace("WH", ""));
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Europe/Vienna"))
.withHour(Integer.parseInt(timeStamp.split(":")[0]))
.withMinute(Integer.parseInt(timeStamp.split(":")[1]));
Message message = new Message(wattH,now);
System.out.println(message);
service.addToPackage(message);
scheudler.check();
}
Stack Output if i cut the Connection:
2022-09-20 07:50:09,683 ERROR [io.sma.rea.mes.mqtt] (vert.x-eventloop-thread-0) SRMSG17105: Unable to establish a connection with the MQTT broker: java.net.SocketException: Connection reset
If the Connection is back:
2022-09-20 07:50:26,751 INFO [io.ver.mqt.imp.MqttClientImpl] (vert.x-eventloop-thread Connection with 192.168.1.88:1883 established successfully
So the connection seems to be back, but there are no more incoming messages.
I solved the Problem by myself.
I set :
quarkus.arc.remove-unused-beans=none
And now it works fine.
I tried many ways to fix the problem, but this seems to be the issue.
I think there is some bean removed in the runtime when the connection is lost for a too long time.
If anyone can explain why this happens please tell me
I am using Twilio's latest SDK they released on CocoaPods as of today. I am trying to implement VOIP feature to my app with Twilio Programmable Voice. My backend is .net which also uses the latest release of Twilio Helper Library for C#.
My client code looks like:
fetchAccessToken { (accessToken: String) in
TwilioVoice.register(withAccessToken: accessToken, deviceToken: deviceToken) { (error) in
if let error = error {
NSLog("An error occurred while registering: \(error.localizedDescription)")
}
else {
NSLog("Successfully registered for VoIP push notifications.")
}
}
}
What I get in the console is as following:
voipTestWithTwilio[2431:517236] [ERROR TwilioVoice] Inside register:deviceToken:completion:, failed to register for Twilio push notifications. Error:Invalid access token signature
voipTestWithTwilio[2431:517236] An error occurred while registering: Invalid access token signature
This is the C# code that actually creates the token:
var grant = new VoiceGrant
{
OutgoingApplicationSid = outgoingApplicationSid
};
var grants = new HashSet<IGrant> { { grant } };
var token = new Token(
accountSid: accountSid,
signingKeySid: apiKey,
secret: apiSecret,
identity: identity,
grants: grants
);
return token.ToJwt();
I have been looking for the issue on the internet, nothing helped so far. I have tried contacting them but have not got any response back. I also tried creating new api keys and even a new project for a couple times on Twilio. Can anybody say something about the issue?
UPDATE
I added push notification sid to VoiceGrant and now I’m getting 403 Forbidden.
On Twilio error codes page it is explained as: “The expiration time provided in the Access Token exceeds the maximum duration allowed.” which is definitely not my case. However, I tried passing expiration parameter in Token constructor with various values which didn’t change the result.
The problem is still persisting.
I solved the issue. It was because my server returned the token with quotation mark.
I remember print(token)'ing on client (iOS) to see whether there is encoding issue or something and all I see was a proper token between quotation marks. Since token is a string value, I didn't pay attention to quotation part of it. That's where I was wrong.
1> Just want to understand how SignalR 1.x functions in a particular scenario
Lets say we have a 10 clients connected to Hub and one of the connected clients say client-1 performs a postback so OnDisconnected is called than OnConnected is called right ?
What happens if during this phase if client-2 try's to send message to client-1 exactly between the said scenario ie (msg is sent after client-1 is disconnected and before connected again )will client-1 miss the message or there's internal mechanism which makes sure client-1 does not miss the message sent by client-2
2> Second query I have is that I'm trying to pass a querystring using following code
var chat = $.connection.myHub;
$.connection.myHub.qs = { "token": "hello" };
but not able to retrieve it on the server side from the Context object
using
Context.QueryString.AllKeys
I even tried
var chat = $.connection.myHub;
$.connection.myHub.qs = "token=hello" ;
But it does not work ie when I check the keys, token is not present in AllKeys
Will appreciate if someone just help me out.
1: If a postback occurs a client will disconnect and then connect. However, when the client performs a connect again it will have a different Connection Id than it had prior to the postback. Therefore, any message sent to the old connection id will be missed because when the users browser connects again it will be known as a different client.
2: You're trying to set the query string on the hub proxy, not the connection. What you should be doing is:
$.connection.hub.qs = { foo: "bar" };
I've been searching Google for awhile and there seems to be no offers on fixing this problem I have here.
I am using LuaSocket as a simple way to connect to a external server I created, and I am able to connect to it successfully and send a signal.
However, when I try to send a second message later on, the external server does not seem to be receiving the message, even though I am still connected to the socket.
socket = require("socket")
host, port = ip, port
tcp = assert(socket.tcp())
tcp:settimeout( 0 )
tcp:connect(host, port);
msg = {
["status"]="connect",
["usrName"]=username
}
msg = Json.Encode(msg)
tcp:send(msg); -- This message, the server received this message.
-- Later in my code, I attempt to send another message.
msg = {
["status"]="anotherMessage",
["usrName"]=username
};
msg = Json.Encode(msg)
tcp:send(msg); -- This message is not sending, even though i'm still connected.
You need to show what happens on the other side as it may be simply not reading even though the connection may be open. You also don't say what exactly happens when "message is not sending"; do you get an error? the script finishes but the message is not sent?
There are several things you can try:
Switch to the (default) synchronous send until you get it working; remove tcp:settimeout(0), as your send may simply fail with "timeout" message if the other side is not ready to read the message.
Check the error message from :send call to see if it's timing out or not.
local ok, err = tcp:send(msg)
Use socket.select to check if the other side it ready to accept the message you are sending.
Try adding "\r\n" at the end of your serialized JSON.
In order to understand how the Push service in BlackBerry is implemented, I have installed the Push Service SDK and following the Push_Service_SDK-Getting_Started_Guide. Following ths steps thoroughly, on "Registering" myself from the app, I got the following error:
Request to register failed. Caused by java.io.IOException: Network operation [Subscribe] failed. Make sure that Content Provider URL is accesible.
Can anyone guide me through this. When keying in the details, we need to provide the "BPS server URL" and "Push Initiator application URL". I have received the credential details from BlackBerry and it contains PPG Base Url as "cpXXX.pushapi.eval.blackberry.com" where the XX needs to be replaced by the CPID (Content Provider ID). Is this link to be keyed in for "BPS server URL" and "Push Initiator application URL"? I did key in this and received the above error on "Register".
Please guide.
You should have received a mail with your credentials for both server app and blackberry client app. For the client app, they should look like this:
Application ID: <CPID(4 chars)>-<id(35 chars)>
PPG Base URL: http://cpXXX.pushapi.eval.blackberry.com
Push Port: <port(5 chars)>
As you can see, the App id has two parts. The prefix before the dash is your CPID, and the rest is the id. Then we have an URL where we will need to replace the XXX with the CPID (note that the CPID usually is a 4 digit number, so it would have been better if they had used XXXX as placeholder). Finally the port number which has up to 5 digits.
With those params, in your BB app, you would code something like this:
String id = "<your full app id here>";
String url = "http://cp<CPID>.pushapi.eval.blackberry.com"; //Make sure it is http and not https, and check you have replaced <CPID> with the appid prefix.
int port = <port>;
byte serverType = <PushApplicationDescriptor.SERVER_TYPE_BPAS or
PushApplicationDescriptor.SERVER_TYPE_NONE>;
ApplicationDescriptor descriptor = ApplicationDescriptor.currentApplicationDescriptor();
PushApplicationDescriptor pushDescriptor = new PushApplicationDescriptor(id, port, url, serverType, descriptor);
// This is how we would register the client app:
PushApplicationRegistry.registerApplication(pushDescriptor);
After executing that line, if everything is ok (registration needs some time, a few connections are made), you can check the registration status calling PushApplicationRegistry.getStatus or via the onStatusChange callback.