how to WireGuard disconnect on android studio - wireguard

I'm encountering this error(mentioned above) while developing on Android studio. Although the VPN connection is working fine but I'm unable to disconnect the session. Can anyone please share any insights for this.
`public void stopVpn (){
Backend backend = new GoBackend(this);
Tunnel tunnel = new WgTunnel();
try {
backend.setState(tunnel, DOWN, null);
} catch (Exception e) {
e.printStackTrace();
}
}`

Related

SignalR client hangs on start() on the second session

I have a ASP.Net core web-app published to IIS, the web-app uses SignalR to display notifications. I also have a desktop windows forms application is used to connect to a fingerprint device and is also used to send notification to the web-app that a person just entered so i can display a notification on the web-app about that person.
And everything works fine with one session of the web-app, but if i open another tab for example or browse the web-app from another computer the second one hangs on the connection.start() until i close the first session. and this drives me crazy.
Here is the code.
ASP.net core Hub
public class SignalRServer : Hub
{
public async Task displayNotification()
{
await Clients.All.SendAsync("displayNotification");
}
}
Javascript client code
let connection = new signalR.HubConnectionBuilder()
.withUrl("/SignalRServer")
.configureLogging(signalR.LogLevel.Information)
.build();
connection.on("displayNotification", () => {
getLatestNotification();
});
connection.start();
The windows forms app has two projects the first one is .NET framework 4.5 which uses the fingerprint device API to connect to the device. And the second project is .NET standard which contains the SignalR HubConnection code to connect to server, and HubConnection is used in the first project to connect and send notifications.
windows forms app Hub connection code in .NET standard
public class HubNotification
{
HubConnection connection;
public HubNotification(string Ip)
{
connection = new HubConnectionBuilder()
.WithUrl(Ip + "/SignalRServer")
.Build();
connection.StartAsync();
}
public async Task ConnectAsync()
{
await connection.StartAsync();
}
public void SendNotAsync()
{
connection.InvokeAsync("displayNotification");
}
}
then in the first project i use ConnectAsync and SendNotAsync to send notification when i person enters.
I don't think there is a problem with the desktop app but i posted the code anyway.
I have read that there is a problem with signalR and multiple session but didn't find any solution.

Error while calling FCM backend service from Google AppEngine

I am setting up my first app with FCM (we used GCM) and following the tutorials. I have an Android app and a servlet-based app on GAE Standard. To test it a have a servlet that sends a message to the app.
This was working a few hours ago, I could call the servlet and received the test message on the app, but now I am only getting exceptions in the FirebaseMessaging.getInstance().sendAsync(message).get() method
com.google.firebase.messaging.FirebaseMessagingException: Error while calling FCM backend service
and
java.net.UnknownHostException: accounts.google.com
Sometimes one and sometimes the other.
This is the method the GAE servlet calls. I have checked if the token I was using was correct and it is the one currently active in the Android device.
final static String urlFCM = "https://fcm.googleapis.com/fcm/send";
private static void initFCM() {
FileInputStream serviceAccount;
try {
serviceAccount = new FileInputStream("WEB-INF/Orchestram-e2e1ceeb2481.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("https://orchestram-cerqana.firebaseio.com/")
.build();
FirebaseApp.initializeApp(options);
} catch (Exception e) {
e.printStackTrace();
}
/// TODO:
}
public static String sendFCM(final JSONObject value, final String token, final boolean back) {
initFCM();
Message message = Message.builder()
.putData("score", "850")
.putData("time", "2:45")
.setToken(token)
.build();
try {
String response = FirebaseMessaging.getInstance().sendAsync(message).get();
} catch (Exception e) {
e.printStackTrace();
return "ERROR";
}
return "HECHO";
}
Turns out the problem was billing on this specific project on GAE was disabled. Once enabled it worked again (and I'm still bellow the free tier, so no real cost added)
There might be a case where you are subscribing to topics multiple topics at once. There is a exponential back off at firebase. I derived this from the link here.
https://firebase.google.com/docs/cloud-messaging/android/topic-messaging
Topic messaging supports unlimited subscriptions for each topic. However, FCM enforces limits in these areas:
One app instance can be subscribed to no more than 2000 topics.
If you are using batch import to subscribe app instances, each request is limited to 1000 app instances.
The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM servers will respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded") response. Retry with exponential backoff.

Consuming Signal R service in Desktop application

I am new to SignalR, I want to develop a service using SingalR API’s and Host as selfhost\IIS, now my doubt is How can I consume these message in Client side my client application will be Windows(Desktop) applications.
Main intention is to send Notification from SignalR service to Clients. I would like to know is this achievable.
Please share any tutorials link or similar projects URL
Thanks in Advance
What I do is use .Net events , to wrap the SignlR client functions and connect to the desktop application call backs . like so :
public class Client
{
public delegate void OnReciveMessage(Object message);
public event OnReciveMessage MessageRecivedEvent;
public void ReciveMessage(Object message)
{
if (MessageRecivedEvent != null)
{
MessageRecivedEvent(message);
}
}
}
Yes it's possible. You can connect to a Signal R hub from webclient or winformsclient.
Useful information on this links:
SignalR Chat App in WinForm With Remote Clients
http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-signalr-20-self-host

create an user in google apps using admin sdk api in java

How to create an user in google apps using admin sdk api in java.
If i use
Directory service = new Directory.Builder(httpTransport, JSON_FACTORY, credential).setApplicationName("DirectoryCommandLine").build();
User qq=new User();
qq.set("familyName",request.getParameter("familyName"));
qq.set("givenName",request.getParameter("givenName"));
qq.set("password",request.getParameter("password"));
qq.set("primaryEmail",request.getParameter("primaryEmail"));
qq.set("organizations",request.getParameter("organizations"));
Directory.Users.Insert grequest = service.users().insert(qq);
try {
grequest.execute();
} catch (IOException e) {}
it is not inserting.
You should output the error in your catch block, it would help a lot to debug your problem...

Silverlight out of browser in SharePoint webpart

I have an issue with my Silverlight webpart in a SharePoint 2010 site. The Silverlight app works great in the site and even out of browser. The issue I'm having is how to autoupdate the out of browser app. I currently have this:
if (Application.Current.IsRunningOutOfBrowser)
{
App.Current.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted);
App.Current.CheckAndDownloadUpdateAsync();
}
void Current_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
{
if (e.Error == null && e.UpdateAvailable)
{
MessageBox.Show("Application updated, please restart to apply changes.");
}
if (e.Error != null)
{
MessageBox.Show(e.Error.Message);
}
}
but it doesn't run when it's SharePoint. I have to currently send out an email to all of my users thay may be using this app out of browser and have them uninstall and install it again. Does this have something to do with how SharePoint uses security? When a user double clicks on the desktop icon to open the oob app, it does give a credential login. My guess is that's what's throwing off the auto update.
Thanks!
The fix was to sign the xap files and place this code after authentication takes place!

Resources