Port 9553 (from Firebase) blocked by webhost, can't find a way to successfully cURL over alternate port - nest-api

I'm using PHP and cURL with the REST api, and even though I can cURL the initial Nest Developer api endpoint, once it redirects to Firebase's url it's over port 9553, which my webhost has blocked (no chance to get opened up either). The connection times out and throws the 'could not connect to host' error.
My code is working fine, I can run it on my local server with no problems.
I'm new at using cURL, what are my options? It seems to me that the problem is the port Firebase is insisting on using. I can cURL a number of different locations, over :80 and :443 without problem, just not Firebase's url. Will I need to run through a proxy in order to access the data?
Or, is this something that might be solved by using Firebase's PHP library? I'm not super interested in using it if I don't have to, cURL would do the job nicely, and I don't know really know how it works.

There is no way to get around the redirects with REST, they point to specific ports and hosts in Nest's cloud.
What is wrong with Firebase's Web Sockets client? It is more performant than REST.

joshguerette,
Is your firewall blocking that port?
You can open the port from your c# code with this:
using Microsoft.TeamFoundation.Common;
private void AddPortToFirewall(int portNumber, string name)
{
INetFwMgr icfMgr = null;
try
{
Type TicfMgr = Type.GetTypeFromProgID("HNetCfg.FwMgr");
icfMgr = (INetFwMgr)Activator.CreateInstance(TicfMgr);
}
catch (Exception ex)
{
Debug.WriteLine("Failed in AddPortToFirewall.Activator " + portNumber.ToString() + " " + name + " " + ex.ToString());
return;
}
try
{
INetFwProfile profile;
INetFwOpenPort portClass;
Type TportClass = Type.GetTypeFromProgID("HNetCfg.FWOpenPort");
portClass = (INetFwOpenPort)Activator.CreateInstance(TportClass);
// Get the current profile
profile = icfMgr.LocalPolicy.CurrentProfile;
// Set firewall enabled
if (!profile.FirewallEnabled)
profile.FirewallEnabled = true;
// Set the port properties
portClass.Scope = NET_FW_SCOPE_.NET_FW_SCOPE_ALL;
portClass.Enabled = true;
portClass.Name = name;
portClass.Port = portNumber;
portClass.Protocol = NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP;
// Add the port to the ICF Permissions List
bool portExisted = false;
foreach (INetFwOpenPort p in profile.GloballyOpenPorts)
{
if (p.Port == portNumber && p.Name == name)
{
portExisted = true;
Debug.WriteLine("Windows Firewall inbound list:" + p.Port + " " + p.Name);
break;
}
}
if (!portExisted)
{
profile.GloballyOpenPorts.Add(portClass);
Debug.WriteLine("ServicePort " + portNumber.ToString() + " " + name + " was added into Windows Firewall inbound list.");
}
else
{
Debug.WriteLine("ServicePort " + portNumber.ToString() + " " + name + " has already in Windows Firewall inbound list.");
}
}
catch (Exception ex)
{
Debug.WriteLine("Failed in AddPortToFirewall " + portNumber.ToString() + " " + name + " " + ex.ToString());
}
}

Related

Docusign Listener Argument Null (dev Sandbox)

I have created a webmethod in a C# webservice that listens for Docusign to call when an Envelope status changes:
[WebMethod]
public void DocuSignConnectUpdate(DocuSignEnvelopeInformation DocuSignEnvelopeInformation)
{
//Check if null
if (DocuSignEnvelopeInformation == null)
{
File.WriteAllText("C:\\websites\\DataAPI\\datalog.txt", "Data: " + "Data is null");
}
else
{
string envelopeId = "";
try
{
//Write a line in a file
File.WriteAllText("C:\\websites\\DataAPI\\datalog.txt", "Data: " + DocuSignEnvelopeInformation.ToString());
//Get some data out
envelopeId = DocuSignEnvelopeInformation.EnvelopeStatus.EnvelopeID;
//Write Data to a file
File.WriteAllText("C:\\websites\\DataAPI\\innerdatalog.txt", "Data: " + DocuSignEnvelopeInformation.ToString());
}
catch (Exception ex)
{
// could not serialize
File.WriteAllText("C:\\websites\\DataAPI\\errorlog.txt", "Exception: " + ex.Message);
throw new SoapException(ex.Message, SoapException.ClientFaultCode);
}
}
The issue I am having is that DocuSignEnvelopeInformation argument is not being set when called, so the code keeps terminating at the if==null statement. When I run the envelope data to the API using SoapUI everything works correctly. Any ideas what I'm missing would be appreciated.
EDIT: I wanted to Add the Interface here too since I forgot it originally
[ServiceContract(ConfigurationName = "IOperations", Namespace = "https://www.docusign.net/API/3.0")]
public interface IOperations
{
[OperationContract(Action = "DocuSignConnectListener/Operations/DocuSignConnectUpdate")]
[XmlSerializerFormat]
string DocuSignConnectUpdate(DocuSignEnvelopeInformation DocuSignEnvelopeInformation);
}
When a DocuSign webhook is set to use SOAP mode, the notification is sent as a SOAP request to your server (your listener).
If SOAP mode is off, then the notification is sent as a regular POST request with an XML body.
In your question, you say that
When I run the envelope data to the API using SoapUI everything works correctly
So it sounds like everything is worked as designed.
Ok I finally figured this out, turns out it just wasn't pretty enough so I added a decoration specifically:
[SoapDocumentMethod("http://tempuri.org/DocuSignConnectUpdate",
RequestNamespace = "http://tempuri.org",
ResponseNamespace = "http://tempuri.org",
Use = System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
on the method and now everything works like its supposed too. Now that I look at it, it makes a lot more sense.

DocuSign Login API Timeout Error

I have a c# DOT NET Winforms application that has been working just fine in the developer environment. Yesterday it just stopped working for some reason. No code changes at all. It seems to be timing out while logging in.
private string DocLogin()
{
ErrMsg = string.Empty;
string _accountId = null;
try
{
var _apiClient = new ApiClient(DocuSignURL);
Config = new Configuration(_apiClient);
// configure 'X-DocuSign-Authentication' header
string _authHeader = "{\"Username\":\"" + Username + "\", \"Password\":\"" + Password + "\", \"IntegratorKey\":\"" + IntegratorKey + "\"}";
Config.AddDefaultHeader("X-DocuSign-Authentication", _authHeader);
// we will retrieve this from the login API call
AuthenticationApi _authApi = new AuthenticationApi(Config);
LoginInformation _loginInfo = _authApi.Login();
_accountId = _loginInfo.LoginAccounts[0].AccountId;
}
catch (Exception ex)
{
_accountId = null;
ErrMsg = ex.Message;
}
return _accountId;
}
As soon as it hits the line "_authApi.Login()" it hangs up then throws the error, "Error calling Login: The operation has timed out".
Any ideas? Remember there has been no code changes and was working fine. I thought about corporate firewall but I tried it outside of the firewall with the same results.
Seems DocuSign stopped TLS1.0 support. See Amit's post above for the link to the solution.

Vertx client for sending get request with parameters

I am writing client in Vertx for sending get request with two string parameters but i am receiving empty list from server. If i write request to another service which is on the same path but this service is not receiving any parameters the response is ok and the data is properly returned. The problem is with mapping the parameter on server side with .addQueryParam the parameter is not mapped well on server side. any help?
WebClient client = WebClient.create(vertx);
client
.get(80, "localhost", "/mainpath/path1")
.addQueryParam("startDate", "1459926000")
.addQueryParam("endDate", "1459926900")
.send(ar -> {
if (ar.succeeded()) {
HttpResponse<Buffer> response = ar.result();
JsonArray body = response.bodyAsJsonArray();
System.out.println("Received response with status code " + response.statusCode() + " with body " + body.toString());
} else {
System.out.println("Something went wrong " + ar.cause().getMessage());
}
});
}

Cassia method works fine in console app but error in asp.net app

I am running this code.
server.Open();
//Console.WriteLine("----------------------------------------------------");
//Console.WriteLine("Active users on {0}", machineName);
foreach (ITerminalServicesSession session in server.GetSessions())
{
System.Security.Principal.NTAccount account = session.UserAccount;
if (account != null)
{
if (session.ConnectionState == Cassia.ConnectionState.Active)
{
((TextBox)Page.FindControl("txt" + machineName.Substring(7))).Text += session.UserName + " idle " + session.IdleTime.TotalMinutes + " minutes" + "\r\n";
}
}
}
It runs fine in console application but gives "No more data is available " error in asp.net page.
I created a new Application Pool in IIS 7 and set its identity as my personal username instead of the default AppIdenitity. Then I assigned this new Application Pool to my ASP.NET web application in IIS. Issue fixed.

C# LDAP SetPassword throws The RPC server is unavailable

I am trying to create a new user -> set password and enable account .
earlier i was using 1 single object , but after looking at a few posts i decided to use 'using' for 3 different operations
string strDisplayName = txtFirstName.Text + " " + txtLastName.Text;
string strUser = txtLoginName.Text;
string pw = "pass#123";
using (var objADAM = new DirectoryEntry("LDAP://" + adlink + "/CN=Users,DC=SS,DC=COM", "ss\\luser", "pass#123", AuthenticationTypes.Secure))
{
const long ADS_OPTION_PASSWORD_PORTNUMBER = 6;
const long ADS_OPTION_PASSWORD_METHOD = 7;
const int ADS_PASSWORD_ENCODE_CLEAR = 1;
string strPort = "389";
int intPort = Int32.Parse(strPort);
using (var objUser = objADAM.Children.Add("CN=" + strUser, "user"))
{
objUser.Properties["sAMAccountName"].Add(strUser);
objUser.CommitChanges();
}
}
using (var user = new DirectoryEntry("LDAP://" + adlink + "/CN=" + strUser + ",CN=Users,DC=SS,DC=COM", "ss\\rluser", "pass#123"))
{
user.Invoke("SetPassword", new object[] { "password" });
user.CommitChanges();
}
using (var user = new DirectoryEntry("LDAP://" + adlink + "/CN=" + strUser + ",CN=Users,DC=SS,DC=COM", "ss\\rluser", "pass#123"))
{
//Enable account and change password on first logon flag
user.Properties["userAccountControl"].Value = 0x200;
user.Properties["pwdLastSet"].Value = 0;
user.CommitChanges();
}
I must mention, that i am outside the domian, and trying to connect to a remote AD on another domain . The credential's passed however are the ADMIN
The user creation goes on smoothly (after some hiccups with port opening & LDAP connections) , but the issue occurs when the invoke ->setpassword is called .
The error is :"the RPC server is unavailable " , just to make sure i am not doing something wrong in my code, i downloaded a LDAP admin tool and tried to reset the password of an existing user ->same error
steps
-checked the RPC service running
-opened RPC ports -135 ,blah blah..basically every port there is to open :|
any help is appreciated .
Thanks
Rajat
For example:
DirectoryEntry de = new DirectoryEntry();
de.Path = "LDAP://dnsname.domain.com:389/OU=Companies;
Microsoft recommends accessing using DNS.
if the machine you are accessing is connected to a different domain, you must specify it as "ip dnsname" in the hosts file in the "C:\Windows\System32\drivers\etc " directory.
using adlink is string domain, because AD method Invoke using domain name: "abc.com"

Resources