Restart RPI 3 Model B Andoid Things remotely - raspberry-pi3

I want to restart my raspberry pi 3 model B remotely. I am running Android Things OS on RPi.
Can anyone tell how can I do this?

You will need to create your own remote service provider to send commands through the device such as Firebase Cloud Messaging. Then, you can use the DeviceManager API on Android Things with the reboot method.
DeviceManager deviceManager = DeviceManager.getInstance();
deviceManager.reboot();
Make sure you set the permission in your manifest too.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidthings.updatemanagersample">
<uses-permission android:name="com.google.android.things.permission.REBOOT" />
<application android:label="#string/app_name">
</application>
</manifest>

Related

BizTalk An attempt to connect to "BizTalkMgmtDb" SQL Server database on server "DB" failed

I'm running BizTalk production environment on two separate virtual machines (Hyper-V) , lets call them APP and DB. They are in the same network, tied with domain controllers. I use 2 our company DNSes on my network adapters in my VMs and virtual switch in my virtualization host.
Problem is sometimes DB got the error that cannot authorize APP which is a blocker - everything goes down. I can't find any pattern to it, this happen in 3 - 6 months period and its totally random to me.
First I blamed the domain, but there are no logs about it in domain controller hosts. I also blamed network but also admin of network has none info about any failure nor do I.
Advice me what to monitor and how to detect what is wrong.
From APP perspective there is an error:
An attempt to connect to "BizTalkMgmtDb" SQL Server database on server "DB" failed.
Error: "Login failed. The login is from an untrusted domain and cannot be used with Windows authentication."
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="BizTalk Server" />
<EventID Qualifiers="49344">6913</EventID>
<Level>2</Level>
<Task>1</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2020-04-28T13:51:48.000000000Z" />
<EventRecordID>2831238</EventRecordID>
<Channel>Application</Channel>
<Computer>APP.mydomain.com</Computer>
<Security />
</System>
<EventData>
<Data>DB</Data>
<Data>BizTalkMgmtDb</Data>
<Data>Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.</Data>
</EventData>
</Event>
From DB perspective I've got following error :
SSPI handshake failed with error code 0x80090311, state 14 while establishing a connection with integrated security; the connection has been closed. Reason: AcceptSecurityContext failed. The Windows error code indicates the cause of failure. [CLIENT: APP IP].
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="MSSQLSERVER" />
<EventID Qualifiers="49152">18452</EventID>
<Level>0</Level>
<Task>4</Task>
<Keywords>0x90000000000000</Keywords>
<TimeCreated SystemTime="2020-04-28T13:51:48.000000000Z" />
<EventRecordID>712620</EventRecordID>
<Channel>Application</Channel>
<Computer>DB.mydomain.com</Computer>
<Security />
</System>
<EventData>
<Data>[CLIENT: APP IP]</Data> <Binary>144800000E0000000900000042005400500052004F004400300032000000070000006D00610073007400650072000000</Binary>
</EventData>
</Event>
and the second:
Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. [CLIENT: APP IP]
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="MSSQLSERVER" />
<EventID Qualifiers="49152">17806</EventID>
<Level>2</Level>
<Task>4</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2020-04-28T13:51:48.000000000Z" />
<EventRecordID>712614</EventRecordID>
<Channel>Application</Channel>
<Computer>DB.mydomain.com</Computer>
<Security />
</System>
<EventData>
<Data>80090311</Data>
<Data>14</Data>
<Data>AcceptSecurityContext failed. The Windows error code indicates the cause of failure.</Data>
<Data>[CLIENT: APP IP]</Data>
<Binary>8E450000140000000900000042005400500052004F00440030003200000000000000</Binary>
</EventData>
</Event>
After today whole-day investigation I know that it looks like something/somebody disabled APP and DB NICs - (there is no log for disabling it tho). It is definitely network related problem but I don't know how to monitor or troubleshoot it. Maybe there is something wrong with Hyper-V itself ?
Do you have a cluster failover for your Hosts instances? I encountered a similar problem when clustering our hosts instances. I opened an incident ticket with Microsoft , after a lot of investigation we wasn't able to find the root cause, we simplu uninstalled the cluster service. Microsoft support used a tool (a .Net console app) they scheduled every 1à sec , to open/close a connection from each Biztalk server to Db server and log the exception messages. It's a network related problem
I have discovered this thread:
https://support.microsoft.com/en-us/help/2986895/virtual-machines-lose-network-connectivity-when-you-use-broadcom-netxt
There is an issue with broadcomm drivers and VMQ settings which applies in my environment.
I'll try to turn VMQ down in my next service window.

Bad Request - Invalid Hostname when accessing localhost Web API or Web App from across LAN

I have an ASP .Net Core 1.1 Web API and Web App running on my localhost from Visual Studio 2017 on Windows 10.
When I run the projects, the API runs on http://localhost:50082/api/ and the web app on http://localhost:60856/
However, if others on the LAN try to access it (using my computer's IP address - http://192.168.1.101:60856/ they get a
Bad Request - Invalid Hostname
Error. In fact,. I get this error too of I use my IP address. I've tried about a dozen variations in my C:\Users\Documents\IISExpress\config\applicationhost.config file, such as:
<bindings>
<binding protocol="http" bindingInformation="*:60856:localhost" />
</bindings>
and
<bindings>
<binding protocol="http" bindingInformation="*:60856:" />
</bindings>
restarting the projects (and therefore IIS Express) every time, but nothing seems to work. Any ideas?
IIS Express does not allow remote connections by default. This post explains how to activate it.
In my opinion, you would be better off if you setup local IIS and publish the app to the configured IIS folder.
I already tried HTTP.SYS configurations for other situations, and sometimes the configs are lost whether on restarts or windows updates... But this may not happen to you...
If you are using asp core, another solution is to simply change your profile from 'IIS' to 'Standalone' (which is named as your project) from Visual Studio toolbar:
By this change, IIS will not run anymore and the embedded asp web server 'kestrel'
will face the requests directly.
If it's still give you host invalid error adjust your hostname settings by adding this line to your config file:
"AllowedHosts": "*",
More info:
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/?view=aspnetcore-5.0#set-up-a-reverse-proxy
https://weblog.west-wind.com/posts/2019/Mar/16/ASPNET-Core-Hosting-on-IIS-with-ASPNET-Core-22
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/host-filtering?view=aspnetcore-5.0
I had this same issue trying to get ngrok to point to a local ASP.NET Core website.
This guy's answer worked for me: https://kodlogs.com/blog/532/iis-express-http-error-400-the-request-hostname-is-invalid
Basically, in the [solution dir]\.vs\[asp.net core web app dir]\config\applicationhost.config file, change the line from:
<binding protocol="https" bindingInformation="*:[your port]:localhost" />
to:
<binding protocol="https" bindingInformation="*:[your port]:*" />

Azure Todo List on Local

Sorry if this is an easy question or solution can be found easly but I can not find it. Unfortunatelly on web finding what you need about Azure is nearly impossible for me as because maybe I don't know how to search because I am a very beginner level web programmer and just started mobile and Azure.
I started native Android development with .Net backend and begin with the tutorial on Azure web page. Now I have the service and mobile app up and running with out any problem. But I can't run and debug it locally. I downloaded the service and when I run it a web page is opened with "http://localhost:59220" address. My machine and phone that I am using for testing is on the same network. I configured my firewall and can telnet it. But phone can not connect to it. Also I can not connect to web page from phone or another computer on the same network. When I try with "192.168.1.100:59220" adress "I got Bad Request - Invalid Hostname HTTP Error 400" error both from phone other computer and also from the computer that runs the service. But when I change ip to localhost it works.
How can I connect my phone and debug my todolist service while running on local?
Thank you.
The answer of urig is the solution that I was looking for but a little addition is needed. If you are using VS2015 applicationhost.config is located on "solution folder of your project".vs\config folder.
Your phone cannot access your local server as "localhost". This hostname is mapped to IP address 127.0.0.1 and on your phone that address points to the phone itself and not to the computer you're running the website on.
When you try with 192.168.1.100, your request does reach the local server and is most likely received by IIS Express - the web server built into Visual Studio which runs your project by default.
IIS Express, however, responds to your request with a Bad Request - Invalid Hostname HTTP Error 400. That is because "192.168.1.100" is not a hostname it is familiar with.
To get a proper response you will need to configure IIS Express to accept requests from 192.168.1.100 or some other hostname. Below are instructions on how to do so, adapted from this blog post: IIS Express – HTTP Error 400. The request hostname is invalid.
Exit the IIS Express instant currently running.
Open IIS Express’s applicationhost.config located at the following path C:\Users\<user>\Documents\IISExpress\config\applicationhost.config
Find the entry for a particular site (e.g “Azure Todo List” running in port 59220) which you are developing.
e.g.:
<site name="AzureTodoList" id="10">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\Projects\BB Apps\AzureTodoList" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:59220:localhost" />
</bindings>
</site>
Replace bindingInformation="*:59220:localhost" with bindingInformation="*:59220:*"
Note: This will make your website ignore the hostname when it responds to requests. This is not the most secure thing to do.
Save the file.
Start a command prompt in administrator mode and run the following command.
netsh http add urlacl url=http://*:6306/ user=Everyone
Now debug the site again and you should be able to access the url using IP address or host name.

How to set application insights SDK proxy configuration?

I’ve built a .NET Windows Service that keeps monitoring the DB latency from a Web Server. Every time the test runs it sends a Metric to App Insights via the SDK. On my development machine all works fine, but when it’s deployed to the webserver the metrics doesn’t reach the App Insights service because a proxy authentication failure occurs. This is the error that I’ve found by analyzing the network activity:
Proxy Authentication Required. Authentication Failure.Please check your username and password.
How can I set the proxy settings for App Insights for my Windows Service? Is there something similar to the “ApplicationInsights.config” file of web sites?
Many thanks in advance!
Finally I figure it out. What I was missing is setting the proxy on the app.config file adding:
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>

Set application pool in IISExpress to a specific domain user

I am using Visual Studio 2012 to build an MVC web application, and IIS Express to host it on my local machine. In order to access specific domain resources (SQL Integrated authentication, file systems, etc.) I have the need to configure the identity that the application pool runs as.
If I instead host it using IIS, it works as intended.
In my applicationhost.config file:
<system.applicationHost>
<applicationPools>
<add name="MyPool" managedRuntimeVersion="v4.0" managedPiplelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true">
<processModel indentityType="SpecificUser" userName="Domain\UserName" password="Password" />
</add>
</applicationPools>
<sites>
<site name="MySite" id="1">
<application path="/" applicationPool="MyPool">
....
</application>
<site>
<sites>
</system.applicationHost>
If I set default to run as the specified pool, it works correctly, but I can't get a specific site to run under the different app pool.
<applicationDefaults applicationPool="MyPool" />
I've seen numerous posts around the interwebs saying that the configuration I have should work, but it doesn't, so what am I missing?

Resources