It's the first time I'm using PuTTY + dedicated Linux Server.
I have installed the MySQL server client on my dedicated Linux server:
apt-get install mysql-server
After installing, I had to set the MySQL Server password, which is what I did.
I have then created a database and a table, which I inserted one row into.
CREATE DATABASE frag_huans;
use frag_huans;
CREATE TABLE hero_data (
-> ID int(2),....);
INSERT INTO hero_data VALUES ('1',...);
this is literally all I have done so far in regards to PuTTY.
What I now tried to achieve, was connecting to the database via my C# Class (in Unity3D).
I've done this with my localhost (xampp) server and it worked fine.
string constr = "Server=localhost;Database=letzter;User ID=root;Password=;Pooling=true";
Now I wanted to connect to the Linux MySQL database the same way:
string constr = "Server=myServerIP;Database=frag_huans;Uid=root#serverIP;Pwd=myPassword";
where "myServerIP" is definitely my servers IP and the Uid is the ID that gets shown in PuTTY at the start of the command line.
The connection won't set up, Unity debugger prompting:
MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts. ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it.
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) [0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket+Worker.Connect () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at MySql.Data.MySqlClient.NativeDriver.Open () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Driver.Open () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver () [0x00000] in <filename unknown>:0
UnityEngine.Debug:Log(Object)
HeroDB:Awake() (at Assets/Preload/HeroDB.cs:51)
Using another value at "Server=..." tells me that the host can't be found which ensures me that my host address seems to be correct.
I have also tried to create another "user" for the MySQL Server + grant this one all privileges:
CREATE USER fh#myServerIP IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES on frag_huans.* to fh#myServerIP;
FLUSH PRIVILEGES;
Changing the connection string to the user shown above didn't change the outcome.
I believe that the Linux server/MySQL database blocks my access. Is there any privileges I have to set to the connection? What could be a possible cause for this problem? I've seen many people having the "No connection could be made because the target machine actively refused it" - issue, but there seem to be too many different cases.
If you can help me in any way, I would be very happy
Thanks in advance, Cshaprest
Try below commands from client machine # telnet <serverip> 3306
If first point fails, Check if there is Firewall rule to accept all incoming mysql connections on port 3306.
Server accept connections from all ip's if mysql id binded to 0.0.0.0 check it in /etc/my.cnf
It's just for confirmation , I assume you have added client IP[not the server IP] in below user creation command.
GRANT ALL PRIVILEGES on frag_huans.* to fh#myclientServerIP;
FLUSH PRIVILEGES;
Related
I have created a PCL in Visual Studio targeting: .NET 4.5, Windows Phone 8, Windows Store Apps, Xamarin Android and Xamarin iOS.
This PCL integrates with the YouTube Data API v3 via HttpClient requests (have some issues using the client library directly).
I have written and successfully run unit tests which test this integration in Visual Studio (test project referencing PCL project), however, when I consume those methods in a Xamarin Android project (in Xamarin Studio) I am getting a Forbidden 403 error on one of the GET methods (search.list - GetStringAsync below), POST methods appear to work fine.
The method in question is as follows:-
public async Task<Google.Apis.YouTube.v3.Data.SearchListResponse> GetVideosForChannelManual(string channelId, string apiKey, string pageToken)
{
var requestString = "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50";
requestString += "&channelId=" + channelId;
requestString += "&key=" + apiKey;
if (!String.IsNullOrEmpty(pageToken))
{
requestString += "&pageToken=" + pageToken;
}
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var task = await client.GetStringAsync(requestString);
var deserializedResponse = JsonConvert.DeserializeObject<Google.Apis.YouTube.v3.Data.SearchListResponse>(task);
return deserializedResponse;
}
}
The detail of the exception is below:-
[0] {System.Net.Http.HttpRequestException: 403 (Forbidden)
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode () [0x00000] in <filename unknown>:0
at System.Net.Http.HttpClient+<GetStringAsync>c__async5.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[System.String].GetResult () [0x00000] in <filename unknown>:0
at YouTubeHelpers.YouTubeRepository+<GetVideosForChannelManual>d__27.MoveNext () [0x000fa] in c:\...\YouTubeRepository.cs:187
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[Google.Apis.YouTube.v3.Data.SearchListResponse].GetResult () [0x00000] in <filename unknown>:0
at YouTubeHelpers.YouTubeRepository+<GetAllVideosForChannelManual>d__20.MoveNext () [0x00061] in c:\..\YouTubeRepository.cs:160 } System.Net.Http.HttpRequestException
My initial thoughts are that the Http request headers are different when running it on Android compared to directly in VS and so attempted to compare in Fiddler using a reverse proxy on the emulator (problem exists in emulator and on hardware device), but I was unable to get the app to send web traffic through the proxy (even though browser traffic was sent to fiddler correctly).
Presumably the HttpClient handler would have to be set for this proxy, but with limited access to System.Net libraries in the PCL it wasn't clear how to achieve this.
Is there something which I should be setting additionally for these GET requests bearing in mind that in the POST requests (insert like, insert subscription for example) where I explicitly send an OAuth2 token as an authentication header (required) work fine?
Any advice would be appreciated.
UPDATE
Tried using ModernHttpClient, but the exception still persists. Still feel this is something to do with the request headers, but no smoking gun as yet.
So the issue was limited to the YouTube data API and not a generic PCL issue (thankfully). It seems that when making an unauthenticated request to the YouTube API (such as search etc) then you need to use the Web API Key, rather than an Android API key?! Even though when making an authenticated request (using OAuth2) you need to use the Android Key and associate the request with the solutions SHA1 key. Hopefully this may help someone else if they encounter this issue too.
I suppose this does raise the question of why there is an option to add an Android API key for the Public API access when it doesn't appear to work and the Web API key should be used?
I have a very odd problem. I have a REST API that uses ServiceStack that does a few things like save payment data etc. From within that API I start building payment object so I can fire off a payment to a Payment Gateway. This payment gateway is a Soap API Using SoapHttpClientProtocol.
The problem I am having is that the Soap API Times out. I have a stack trace that lead me to believe it is happening inside the framework somewhere.
System.Net.WebException: Error: ConnectFailure (Connection timed out) ---> System.Net.Sockets.SocketException: Connection timed out
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.GetRequestStream () [0x00000] in <filename unknown>:0
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (System.String method_name, System.Object[] parameters) [0x00000] in <filename unknown>:0
Above is the exception I got so I believe it is happening inside the Invoke method. Here is the code which is in the proxy file.
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("paymenturl", RequestNamespace="gatewayurl", ResponseNamespace="gatewayurl", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)]
public string SubmitPayment(string trnXML) {
object[] results = this.Invoke("SubmitPayment", new object[] {
trnXML});
return ((string)(results[0]));
}
Does anyone know why this would happen?
Now the SOAP Payment API works though the UI. So if call it straight from the UI I can make a payment and get a successful response back. When I do it from the API it doesn't work.
Is this perhaps a Architectural problem which does not allow an API call from within another API?
Has anyone come across anything like this before?
Any help will appreciated.
Found the problem. It was because there was a mono.security.dll in my bin folder. This is not needed apparently so removed it. Once I did that it worked.
Credit goes to this Post: Mono Apache2 HttpWebRequest crashes with "The request timed out"
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I've just spent two days on this. This is run in the game engine Unity3D, but that shouldn't make a difference. These two lines ALWAYS fail:
TcpClient client = new TcpClient();
client.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 15219));
The error I get is:
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it.
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) [0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
at System.Net.Sockets.TcpClient.Connect (System.Net.IPEndPoint remote_end_point) [0x00000] in <filename unknown>:0
at StreamIn.Connect (System.String server, System.String message) [0x00011] in C:\XXX\StreamIn.cs:41
UnityEngine.Debug:Log(Object)
StreamIn:uPrint(String) (at Assets/StreamIn.cs:27)
StreamIn:Connect(String, String) (at Assets/StreamIn.cs:77)
StreamIn:Start() (at Assets/StreamIn.cs:18)
I've tried everything, including changing my firewall settings and disabling the firewall.
I get the same error with a dummy IP address.
If I try port 80 instead of 15219, the Unity editor freezes. (I do have a web server running.)
Am I missing something obvious? Or not obvious?
I always find it useful to sanity check these things with a different network tool outside of my .NET code. I think hercules is great for this as you can easily open up a tcp server for you app to connect to, and/or test a connection from a client perspective.
I have a .NET program running on Ubuntu via Mono 2.10
The program downloads a webpage via an HttpWebRequest every minute or so which works fine most of the time:
String result;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
using (objResponse = objRequest.GetResponse())
{
using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()))
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
}
The problem is that after few days I start getting exceptions thrown:
DateTime: 01/25/2012 08:15:41
Type: System.Net.WebException
Error: Error: NameResolutionFailure
Stack:
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
at socks_server.Program.readHtmlPage (System.String url) [0x00000] in <filename unknown>:0
at socks_server.Program.getAccessKeysProc () [0x00000] in <filename unknown>:0
The server is still abel to resolve DNS, for example
wget http://www.google.com
Will return the file without any probelm as will ping and other commands that resolve DNS.
My program however will continue to throw that exception until I restart it. After restarting the application it will start working again as it should.
I have checked open file counts on the system (400 ish), memory usage (327mb of 4gb), CPU usage (2-3%) and all are OK.
Any ideas?
You can solve it by translating the host name to ip and add the host name to Headers collection or to Host property.
If your url is http://example.com/uri. Resolve the host yourself. Suppose its 1.2.3.4. It'll be http://1.2.3.4/uri. Now add Host: example.com header to your request. I think it can be done by setting HttpWebRequest.Host property.
I know this is an old post, but was facing the same error, so thought to share the solution.
The best solution I found, when that exception occurs while the Wifi
is connected, is just to retry my server call with a slight sleep in
between. It works most of the time, otherwise if the second call
fails I cancel the request.
This error can also raise if the user's Wifi is very unstable or the
signal is very low. The same error occurs if there is no internet
connection at all, even if connected to Wifi.
This is in line with my ans on :
System.Net.WebException: Error: NameResolutionFailure when Calling WCF Services throwing exception in mono android application
Well I use the HttpClient - but it might be a similar problem. I had the same issue on a Android device (it worked on a Windows Phone)... But after I added the Host to the header it worked!
client.DefaultRequestHeaders.Host = "mydomain.com";
You can still use the name in the url (you don't have to use the IP address)
I was experiencing the same issue in my mono application on raspbian. I've tried different solutions described in this and other threads but none worked. Eventually, I was able to fix the problem by changing the name servers in /etc/resolv.conf to the google ones https://developers.google.com/speed/public-dns/
Mirko
I was getting this error when I started the mobile app (android or iOS it does not matter) without internet connection. After restored the connection every request returns "NameResolutionFailure exception". I had to wait 120 seconds for having the http request working again. Setting the following line of code anywhere in the app startup the error was finally gone.
System.Net.ServicePointManager.DnsRefreshTimeout = 0;
The default DnsRefreshTimeout value is 120 seconds.
I have a Subject<T> that I'm publishing items into via OnNext and after a while, under load, I get this exception:
System.NullReferenceException: Object reference not set to an instance of an object
at System.Diagnostics.ExceptionExtensions.PrepareForRethrow (System.Exception exception) [0x00000] in <filename unknown>:0
at System.Concurrency.AsyncLock.Wait (System.Action action) [0x00000] in <filename unknown>:0
at System.Concurrency.Scheduler+<>c__DisplayClass4.<Schedule>b__0 () [0x00000] in <filename unknown>:0
at System.Concurrency.ImmediateScheduler.Schedule (System.Action action) [0x00000] in <filename unknown>:0
at System.Concurrency.Scheduler.Schedule (IScheduler scheduler, System.Action`1 action) [0x00000] in <filename unknown>:0
at System.ScheduledObserver`1[GetNotifyd.Superfeedr.FeedItem].EnsureActive () [0x00000] in <filename unknown>:0
at System.Collections.Generic.Subject`1[GetNotifyd.Superfeedr.FeedItem].OnNext (GetNotifyd.Superfeedr.FeedItem value) [0x00000] in <filename unknown>:0
After this happens I can still publish items via OnNext, but my subscriber no longer receives anything. This is running under mono 2.10.1 using the .NET 3.5 Reactive Extensions DLLs from MS (i.e. i don't think it's mono code that's dying). I haven't seen this happen when I try it on windows, but i haven't run the same loads there. The item that is the argument to OnNext is definitely not null, so that's not the cause.
Any idea what might be causing this or how i could recover the Subject, or do i just have to create a new Subject, notify all my subscribers to subscribe to that instead?
Since it looks like an Rx issue, i've also reported it on their forum
Update: The issue was confirmed as a Rx/mono issue for the combinations of versions i was using. Upgrading to latest Rx (1.0.10605) fixed the problem.
You might be hitting a race condition bug in Rx.
Notice in this MSDN thread, a poster had a similar problem: an unexplained NullReferenceException coming from a stack trace that hits AsyncLock.Wait.
Now, his problem was caused by [ThreadStatic] not working on the Windows Phone 7. Is it possible [ThreadStatic] has nuanced behavior on Mono?
I'd recommend reporting this error to the Rx team via the Rx forums.