I tried using Sharp.xmpp as a library for my console application. When I tried to transfer file, it initiates the file transfer and the receiver can accept it (another client using spark), but right after accepting it through the other client, the file transfer gets aborted. I just followed the sample code in documentation.
client.InitiateFileTransfer(recipient, "path_to_file_to_send", "description of the file", FileTransferCallback);
and here is the callback
static void FileTransferCallback(bool accepted, FileTransfer transfer)
{
Console.WriteLine(transfer.To + " has " + (accepted == true ? "accepted " : "rejected ") + "the transfer of " + transfer.Name + ".");
}
same thing happens on here..
I found
client = listener.AcceptTcpClient(timeout);
in Socks5Server.cs and I think this section causes the problem.
There's an exception which is like this.
Exception : 'System.ArgumentNullException'(System.Core.dll)
it occurs when TcpListener.AcceptTcpClient() run after.
if someone found the solution, please share it.
and Solved!
Client.FileTransferSettings.UseUPnP = true;
Client.FileTransferSettings.ForceInBandBytestreams = true;
add this code to anywhere.
Related
I'm new to this Page just now but already got a Question to ask.
Ok, I'm right now on a bigger Project (for me atleast) for a Server Interface of round about 3 Minecraft Servers on one machine.
Now I got to the point where I no longer want to call the startfiles manually, so i created a function that creates a Savefile with the location of the "servers" startfile (it's a simple batchfile) called "(name_of_server)_SAVEFILE(number_of_server).txt".
And now i want the Program to show me (best on startup) how many Servers actually have been saved by asking for the number talked about earlier.
I also want to implement a lock so the filenumber already created can't be saved with another name, but that's a different story there.
I did it like this:
private void checkForServer_button_Click(object sender, EventArgs e)
{
if (File.Exists(#"C:\Users\" + system_user + #"\Desktop\savedServers\*1.txt") == true)
{
string server1_location = File.ReadAllText(#"C:\Users\" + system_user + #"\Desktop\savedServers\*_SAVEFILE1.txt");
checkForServer_response.Text = "There are Servers!";
onlyInfo.Clear();
onlyInfo.Text = "[CONSOLE] Found existing Server! Found at: " + server1_location;
}
}
onlyInfo is a RichTextBox used as a dummy output atm, might stay in the final version to show what the saved batchfiles look like.
Yes, so basically my code does nothing when I click the button.
And another Question, how do I set the "*" properly for this type of usage.
Thanks in advance!
File.Exists does not support wild characters in the file name. And neither does File.ReadAllText.
string[] files = System.IO.Directory.GetFiles(#"C:\Users\" + system_user +
#"\Desktop\savedServers\", "*1.txt");
if (files.Length > 0)
{
string server1_location = File.ReadAllText(files[0]);
...
}
So, I'm fairly certain this is a relatively remedial question with a likely simple solution, but I just can't seem to find it. I've currently got a program that writes the variables it sets to the console on execution, as well as writing them to the logfile when called through Autosys.
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss.fff") + " Output Variable: " + variable1);
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss.fff") + " Output Variable: " + variable2);
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss.fff") + " Output Variable: " + variable3);
Simple stuff. But for some reason, when I call this...
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss.fff") + " Endpoint: " + endpointAddress);
after previously setting
endpointAddress = "https://endpointaddress.com";
for debug
or
string endpointAddress = Environment.GetEnvironmentVariable("ENDPOINT");
for the Autosys call, with ENDPOINT set in the jobvars file to
JV_ENDPOINT https://endpointaddress.com
and JV_ENDPOINT set in the cmd file to
SET ENDPOINT=%JV_ENDPOINT%
with the end result of it pretty much being exactly the same as it is when the program is run through Visual Studio or the executable itself,
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss.fff") + " Endpoint: " + endpointAddress);
is just skipped entirely in the log. The other ten or so WriteLines that are called all work fine, but nothing at all is written in that line's place.
A few lines up in the log file, I get
D:\server_apps\PROCESS_FOLDER>SET ENDPOINT=https://endpointaddress.com
showing that the endpoint is properly set, but not calling it later.
And...this just in...the most recent time I have run it, the endpoint line just WAS put into the log file. Huh. Well, let's adjust this question a bit. Would anyone happen to have any idea why this particular line might be so uniquely temperamental? I haven't changed anything significant in more than an hour, so I can't fathom why it would suddenly work. But any insight into why it may have happened (and why it might not again) could go a long way toward working any bugs or kinks out of this. Hopefully.
As always, thanks for your time!
As I come across issues when testing my current application, I often have to tweak the database the app uses. After losing important changes several times, I wrote a program that will back up my database to a file and then check the file into SubVersion. I have found that that backup application is not good enough.
The database is a PostgreSQL database, and my backup application invokes pg_dump to create the backup file. pg_dump is executed in a console window. When the database was on my own machine, it worked well. But when I moved the database to our test server, pg_dump asked for a password. While it's not that big a deal, I'd like to be able to supply the password automatically, since it is available in the backup application.
I've tried to follow advice I've found here, but pg_dump still stops and asks for a password. Here's the code that I thought should have supplied the password:
Process backupProcess = new Process();
backupProcess.StartInfo.UseShellExecute = false;
backupProcess.StartInfo.RedirectStandardInput = true;
backupProcess.StartInfo.FileName = dumpPath + "pg_dump.exe";
backupProcess.StartInfo.Arguments = " --host " + host +
" --port " + port +
" --username " + userName +
" --format custom --blobs --verbose --file " +
"\"" + txtBackupFile.Text + "\" " + dbName;
backupProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
backupProcess.Start();
StreamWriter standardInput = backupProcess.StandardInput;
standardInput.WriteLine("mypassword");
backupProcess.WaitForExit();// Waits here for the process to exit.
Thank you for your help.
RobR
I have solved this by using
backupProcess.EnvironmentVariables["PGPASSWORD"] = "password";
This way, I avoid the password will be stored on the computer
Maybe it's cheating a little bit (in the sense that it doesn't really help you answer the question of how to feed input to pg_dump), but you could refer to this answer which suggests the use of a .pgpass file. It would certainly be possible to write to this file dynamically rather than try to interact with the program once it prompts.
Info on .pgpass here.
[ My humble request: please don't ignore this question just by adding some reference question link. I read all the reference i can, but i didnt get what i need]
I am trying to make a windows/console application where i need to access the user details offline. So i tried the following code.
String finalRedirectUri = "https://www.facebook.com/dialog/oauth?client_id=" +
_appKey2 + "&redirect_uri=" + _SiteURL + "&scope=email,read_stream";
String GraphUri = "https://graph.facebook.com/oauth/access_token?client_id=" +
_appKey2 + "&redirect_uri=" + _SiteURL + "&scope=email,read_stream";
FacebookClient client = new FacebookClient(_appKey2, _secret2);
FacebookOAuthClient oAuthClient =
new FacebookOAuthClient(FacebookApplication.Current);
oAuthClient.AppId = _appKey2;
oAuthClient.AppSecret = _secret2;
oAuthClient.RedirectUri = new Uri(finalRedirectUri);
String Uri = oAuthClient.GetLoginUrl().ToString();
try
{
dynamic tokenResult =
oAuthClient.ExchangeCodeForAccessToken("offline_access");
}
catch (Exception exp)
{
MessageBox.Show("" + exp.Message);
}
I am always getting error message: " (OAuthException) Invalid verification code format"
I searched many links in stackoverflow and http://developers.facebook.com/docs/authentication/ also but it didnt helped me to find the solution. I dont even know which uri to use.
I am using Visual Studio 2010 [ Please donot simply ignore this question just by marking as duplicate]
Be gentle to me please..
It's possible that if you downloaded the compiled facebook dll (from NuGet for example), that it's badly built. Try downloading the source and compiling it yourself and using that dll.
Here is an example of a post with the same problem.
note even though their problem is giving a different error, it's possible this is precisely the problem you have, as it's in the same function your variant may just be running into another one of their mistakes.
here are two other possible problems you may be having:
Sometimes, redirect uri should be null
OAuth really likes the '/' at the end of a uri
This is a long shot. I have no idea why this is happening, and I am hoping this is something someone else has run into.
I have an email utility that sends me an email whenever a user gets an error, and I use it like so:
MyUtility.SendEmail(shortNTID,
"support#mycompany.com",
new string[] { "supportlist#mycompany.com" },
"Application error has occured for user: " + shortNTID,
"Message: " + ex.Message.ToString() +
" Source: " + ex.Source.ToString() +
" Target Site: " + ex.TargetSite.ToString() +
" Stack Trace: " + ex.StackTrace.ToString());
Now for some reason today I got some emails from the application that had this in the subject AND the body:
Application error has occured for
user: Example User
That text should only be in the subject. In addition, the rest of the message body was blank, but obviously should have exception details.
To reiterate, there are two wierd things about this:
I have done a search through my application using "Find" for "Application error has occured for user:" and there are only a few places, and nowhere do I have this text in the message body.
The email is supposed to have all that exception information in the message body, and the emails had nothing but that sentence "Application error has occured for user: Example User"
Any ideas what is going on?
Richard,
Check that there isn't a comma [unlikely to affect code, however...!!] (,) embedded inside the shortNTID variable and especially check that ex is in fact not null.
just a very long shot...
Ok so I'm just dumb. My SendMail method in my utility is overloaded and one of the overloads had a mistake where the subject was getting put in for the message. Problem solved. Thanks to all of you for humoring me and trying. . .