Error in when connecting to the wifi in xamarin ios - xamarin.ios

I want to connect wifi in xamarin ios and getting this error:
Error Domain=NEHotspotConfigurationErrorDomain Code=8 "internal
error." UserInfo={NSLocalizedDescription=internal error.}
var wifiManager = new NEHotspotConfigurationManager();
var wifiConfig = new NEHotspotConfiguration(ssid, password, false);
wifiConfig.JoinOnce = false;
wifiManager.RemoveConfiguration(ssid);
wifiManager.ApplyConfigurationAsync(wifiConfig);
wifiManager.ApplyConfiguration(wifiConfig, (error) =>
{
if (error != null)
{
Console.WriteLine(error.GetType());
Console.WriteLine($"Error while connecting to WiFi network {ssid}: {error.LocalizedDescription}");
Console.WriteLine($"Error while connecting to WiFi network {ssid}: {error.Description}");
}
});
}

Related

obs-websocket-js failed to connect. Server sent no subprotocol

I want to use obs-websocket-js package to build an app to connect to OBS Studio through websocket.
When I try running the connection function, I get a Failed to connect -1 Server sent no subprotocol error.
The OBS Studio is running on Ubuntu 20.01 which is on a Oracle VM VirtualBox on my system.
Node.JS code:
const OBSWebSocket = require("obs-websocket-js").default;
const obs = new OBSWebSocket();
const connect = async () => {
try {
const { obsWebSocketVersion, negotiatedRpcVersion } = await obs.connect("ws://192.168.100.170:4444",undefined, {rpcVersion: 1});
return `Connected to server ${obsWebSocketVersion} (using RPC ${negotiatedRpcVersion})`;
} catch (error) {
console.error("Failed to connect", error.code, error.message);
}
};
connect().then((value) => console.log(value));
I expect to make a succesful connection and to find out why I have a Server sent no subprotocol error.
I found a very simple solution: I updated the OBS Studio to the latest 29.0.0 version and it worked.

WebSocket connection to 'wss:<XXX...azure-devices.net/'> failed: Error during WebSocket handshake: Unexpected response code: 400

I am trying to use the azure-iot-device-mqtt in the application. I am trying to connect to the azure iot hub. Following is the code I am using. But whenever I am trying to connect I get the error
'WebSocket connection to 'wss: failed: Error during WebSocket handshake: Unexpected response code: 400'. Can anyone guide me to fix this?
var Mqtt = require('azure-iot-device-mqtt').Mqtt;
var DeviceClient = require('azure-iot-device').Client;
var connectionString = config.hubConnectionString;
var client = DeviceClient.fromConnectionString(connectionString, Mqtt);
// Connect to the IoT hub.
client.open(function (err) {
if (err) {
console.log('Could not connect: ' + err);
} else {
console.log('Client connected');
}
client.close(function() {
process.exit(0);
});
});
I tested your code on my side and it works for me . I am not sure if you missed something,as 400 error likely arguments error.
Anyway , these are the steps I made the code work :
Create a Iot hub.
Register a device here by default and note the deviceID:
find connection string here and use it in your code :
Config the value of connectionString , you should append "DeviceId=<-deviceID value in step2->" to your connection string :
Hope it helps .

How to integrate Azure IOT Hub with Ionic Mobile app?

I need to implement Notifications in my Ionic Application for Android. For that we have set up Azure IOT Hub where the device should get registered and from there, we can send messages to the device and vice versa (from the device to the cloud).
Now, I have gone through lots of links in the google regarding plugins for azure in Ionic, i tried them but in vain. I need to do two things
Register the device ID with the Azure IOT Hub
Send Notification in the Azure IOT Hub using that device ID, so that I can receive it in the device.
I have gone through
https://github.com/Azure/azure-iot-sdk-node
https://github.com/derek82511/cordova-azure-notification-hubs
None of them helped me to register device to the IOT Hub. Can some one guide me in the right direction. I need to know the process how to connect the Azure IOT Hub with my Ionic mobile app for Android.
Code:
var iothub = require('azure-iothub');
var connectionString = config.hubConnectionString;
var registry = iothub.Registry.fromConnectionString(connectionString);
// Create a new device
var device = {
deviceId: uuid
};
registry.create(device, function(err, deviceInfo, res) {
if (err) {
console.log( ' error: ' + err.toString());
this.showAlert('Create Device Error',err.toString());
}
if (res) {
console.log(' status: ' + res.statusCode + ' ' + res.statusMessage);
this.showAlert('Create Device Success Response',`status: ${res.statusCode} ${res.statusMessage}`);
}
if (deviceInfo) {
console.log(' device info: ' + JSON.stringify(deviceInfo));
this.showAlert('Device Info',JSON.stringify(deviceInfo));
}
});
//var clientFromConnectionString = require('azure-iot-device-http').clientFromConnectionString;
//var Message = require('azure-iot-device').Message;
var connectionString = config.hubConnectionString;
var client = clientFromConnectionString(connectionString);
var connectCallback = function (err) {
if (err) {
console.error('Could not connect: ' + err);
this.showAlert('HTTP Connection Error',err.toString());
} else {
console.log('Client connected');
var message = new Message('some data from my device');
client.sendEvent(message, function (err) {
if (err) {
console.log(err.toString());
this.showAlert('HTTP Send IOT Message Error',err.toString());
}
});
client.on('message', function (msg) {
console.log(msg);
this.showAlert('IOT Received Message',msg);
client.complete(msg, function () {
console.log('completed');
});
});
}
};
client.open(connectCallback);
You need to use the IoT Hub Service SDK: https://www.npmjs.com/package/azure-iothub
This example is from that link and shows how to use the device registry to create a new device.
var iothub = require('azure-iothub');
var connectionString = '[IoT Connection String]';
var registry = iothub.Registry.fromConnectionString(connectionString);
// Create a new device
var device = {
deviceId: 'sample-device-' + Date.now()
};
registry.create(device, function(err, deviceInfo, res) {
if (err) console.log('error: ' + err.toString());
if (res) console.log('status: ' + res.statusCode + ' ' + res.statusMessage);
if (deviceInfo) console.log('device info: ' + JSON.stringify(deviceInfo));
});

How to check socket connection is available or not in nodejs stompit

I was use stompit module for connect activeMQ in node js.
My problem : Unable to identify whether broker is connected or not in stompit.ConnectFailover
Here is my code:
var stompit = require('stompit')
var connectionManager = new stompit.ConnectFailover();
connectionManager.addServer({
'host': 'localhost',
'port': 61623,
'connectHeaders':{
...
}
});
var channel = new stompit.Channel(connectionManager);
var subscribeHeaders = {
'destination': '/queue/test',
'ack': 'client'
};
channel.subscribe(subscribeHeaders, function(error, message){
if (error) {
console.log(error);
return;
}
});
//send . But not throw error , even broker is not started
//always trying to reconnect
sendDlQ(subscribeHeaders, 'Hello');
function sendDlQ(header, body){
channel.send(header, body);
}
Whenever call send method , always success.
Even broker is not started.
How to identify broker is connected or not before send ?
Already connection option available from Channel.js from stompit library
check if(channel._client != null && !channel._closed)

Connect to websocket if cloudflare protection is enabled

I am connected to a websocket of some website using node.js and ws module , that usually works fine but recently they re updating something and than they enable cloudflare protection ...
So i get 503 server response when trying to connect
function connect_to_ws(failures) {
if (already_connected) return;
if (failures == undefined) failures = 0;
log('Connecting to "' + ws_server + '"...');
var ws = new WebSocket(ws_server, [], {
'headers': {
'Cookie': cookie
}
});
ws.on('open', function() {
already_connected = true;
log('Connected');
});
...

Resources