I am trying to run ClientContext.ExecuteQuery() and I am getting the following error message:
"The underlying connection was closed: A connection that was expected to be kept alive was closed by the server." >> "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
My code is as follows:
ClientContext _clientcontext = new ClientContext("<URL of sharepoint site>");
NetworkCredential _cred = new NetworkCredential("userid", "password", "domain");
_clientcontext.Credentials = _cred;
Web _site = _clientcontext.Web;
CamlQuery _query = new CamlQuery();
try
{
_query.ViewXml = <View><Where><Eq><FieldRef Name=\"Created\"/><Value Type=\"DateTime\"><Today OffsetDays=\"-4\"/></Value></Eq></Where></View>";
List _splist = _site.Lists.GetById(new Guid("<GUID>"));
ListItemCollection _listitems = _splist.GetItems(_query);
_clientcontext.Load(_listitems);
_clientcontext.ExecuteQuery();
Related
I'm creating a web service that reads a file that contains a XMLA query and execute it against SSAS. My problem is that everything works locally, but when I publish my solution on a Windows Server 2008 R2 an exception keeps being generated.
Here is my code:
private String sendXMLARequest(String sXMLARequest, String sTargetServer, StreamWriter logger)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(sXMLARequest);
String Json = JsonConvert.SerializeXmlNode(doc);
Server server = new Server();
server.Connect(sTargetServer);
server.Execute(sXMLARequest);
XmlaResultCollection rsCollection = server.Execute(sXMLARequest);
string dis = server.Version.ToString();
String s = null;
foreach (XmlaResult res in rsCollection)
{
s += res.Value.ToString();
foreach (XmlaMessage message in res.Messages)
{
logger.WriteLine(message.ToString());
if (message is XmlaError)
Json = s + "ERROR : " + message.Description;
else
Json = s + "WARNIN : " + message.Description;
}
}
server.Disconnect();
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Serialize(Json.ToString()); ;
}
EXCEPTION : Microsoft.AnalysisServices.ConnectionException: A
connection cannot be made. Ensure that the server is running. --->
System.IO.IOException: Unable to read data from the transport
connection: An existing connection was forcibly closed by the remote
host. ---> System.Net.Sockets.SocketException: An existing connection
was forcibly closed by the remote host
I have following problem
While I am trying to connect to the DocumentDB database using MongoDb API:
var cstring = "mongodb://textadmin:<MY VERY SECRET PASSWORD>#<MY SERVER>.documents.azure.com:10250/?ssl=true"
var client = new MongoDB.Driver.MongoClient(cstring)
var server = client.GetServer()
server.Ping()
I have the following error:
Authentication failed because the remote party has closed the transport stream
Any ideas what to change in the code (or in the server settings perhaps)?
You need to set EnabledSslProtocols to TLS12 to be able to connect to DocumentDB using MongoDB API. By default, the Mongo C# driver does not use TLS1.2 causing the connection to fail during SSL handshake.
Sample Code:
MongoClientSettings settings = new MongoClientSettings();
settings.Server = new MongoServerAddress(host, 10250);
settings.UseSsl = true;
settings.SslSettings = new SslSettings();
settings.SslSettings.EnabledSslProtocols = SslProtocols.Tls12;
MongoIdentity identity = new MongoInternalIdentity(dbName, userName);
MongoIdentityEvidence evidence = new PasswordEvidence(password);
settings.Credentials = new List<MongoCredential>()
{
new MongoCredential("SCRAM-SHA-1", identity, evidence)
};
MongoClient client = new MongoClient(settings);
Reference: https://azure.microsoft.com/en-us/documentation/articles/documentdb-mongodb-samples/
I have the below code that connects to RabbitMQ on my local machine but when I change Host name from localhost to my servername it fails and returns the error
var factory = new ConnectionFactory();
factory.UserName = "myuser";
factory.Password = "mypassword";
factory.VirtualHost = "/";
factory.Port = AmqpTcpEndpoint.UseDefaultPort;
factory.HostName = "localhost";
As soon as I change HostName as below, it returns error
factory.HostName = "myserver";
Exception: None of the specified endpoints were reachable
The AMQP operation was interrupted: AMQP close-reason, initiated by
Library, code=0, text=\"End of stream\", classId=0, methodId=0,
cause=System.IO.EndOfStreamException: Peer missed 2 heartbeats with
heartbeat timeout set to 60 seconds
Instead of connecting this way, it's much easier to connect using a connection string like you would with sql.
Example C#:
var factory = new ConnectionFactory
{
Uri = ConfigurationManager.ConnectionStrings["RabbitMQ"].ConnectionString,
RequestedHeartbeat = 15,
//every N seconds the server will send a heartbeat. If the connection does not receive a heartbeat within
//N*2 then the connection is considered dead.
//suggested from http://public.hudl.com/bits/archives/2013/11/11/c-rabbitmq-happy-servers/
AutomaticRecoveryEnabled = true
};
return factory.CreateConnection();
web.config or app.config
<connectionStrings>
<add name="RabbitMQ" connectionString="amqp://{username}:{password}#{servername}/{vhost}" />
</connectionStrings>
On server, it looks like Host Name is configured different. My Admin looked at logs and looked at configuration and provided me with the Host Name on server.
var factory = new ConnectionFactory();
factory.UserName = "myuser";
factory.Password = "mypassword";
factory.VirtualHost = "/filestream";
factory.Port = AmqpTcpEndpoint.UseDefaultPort;
factory.HostName = "myserver";
My Code is below:
MySqlConnectionStringBuilder conn_string = new MySqlConnectionStringBuilder();
conn_string.Server = "mysql.***********.com";
conn_string.UserID = "********";
conn_string.Password = "********";
conn_string.Port = 3306;
conn_string.Database = "*********";
var connectionString = conn_string.ToString();
var connection = new MySqlConnection(connectionString);
connection.Open();
The error that I get is System.TimeoutException
Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
The code worked before when I was on a different network, but now that I have changed networks it no longer works and I get a timeout error on the connection.Open(); command.
Any ideas on what is wrong? I know that the database/server and even the computer I'm using has not changed but my network has.
I am not able to connect remote mongodb from my asp.net application. Though I am able connect it through mongo console.It gives me following error
"An exception of type 'MongoDB.Driver.MongoConnectionException'
occurred in MongoDB.Driver.dll but was not handled in user code
Additional information: Unable to connect to server troup.mongohq.com:10035: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
Also I am able to connect my asp.net application from my local database.
Here is my code to connect mongodb by c#
var connectionString = "mongodb://appuser:xxxxx;#troup.mongohq.com:10035/PowrOfYouDev2";
var client = new MongoClient(connectionString);
var server = client.GetServer();
var database = server.GetDatabase("PowrOfYouDev2");
var collection = database.GetCollection<Entity>("Test");
var entity = new Entity { Name = "Tom" };
collection.Insert(entity);
var id = entity.Id;
var query = Query<Entity>.EQ(x => x.Id, id);
entity = collection.FindOne(query);
string str = entity.Name;
I am inserting image of error
Please help me.
Way late... But is there a reason you had that semicolon in the path?
"mongodb://appuser:xxxxx;#troup.mongohq.com:10035/PowrOfYouDev2
Seems like it should have been:
"mongodb://appuser:xxxxx#troup.mongohq.com:10035/PowrOfYouDev2