TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Andrew James
NA
4
1.3k
Using HttpClient over an SSH tunnel
Jun 3 2021 5:32 PM
I am struggling with sending a POST to an HTTP server that is internal and can only be accessed via SSH from the outside.
What I'm doing is simply entering a number into a textbox then converting it to a byte to be sent with a POST. From the standpoint of the SSH connection it works fine. It's just that it hangs and does nothing after connecting. I'm pretty new to coding something like this.
protected
void
Button1_Click(
object
sender, EventArgs e)
{
var data =
new
{
Number = Number.Text,
};
string
stringdata = JsonConvert.SerializeObject(data);
byte
[] bytedata = Encoding.ASCII.GetBytes(stringdata);
Button1.Enabled =
true
;
SSHSubmits.SIDSubmitByte(bytedata);
}
Then sending it to a function
public
static
void
SIDSubmitByte(
byte
[] fromSource)
{
using
(var sshClient = ClientCreate())
{
sshClient.Connect();
Httpsend(fromSource).Wait();
sshClient.Disconnect();
}
}
The Httpsend looks like this
private
static
async Task<
string
> Httpsend(
byte
[] fromSource)
{
string
consortiumPostAddr =
"http://127.0.0.1:42069/incoming/1/1/testsid"
;
HttpClient httpclient =
new
HttpClient();
ByteArrayContent byteContent =
new
ByteArrayContent(fromSource);
await Task.Delay(3000);
var response = await httpclient.PostAsync(consortiumPostAddr, byteContent);
string
result = response.Content.ReadAsStringAsync().Result;
httpclient.Dispose();
return
result;
}
Reply
Answers (
0
)
JWT is not well formed
how to consume Stored Procedure REST WEB service in Client application