Is there a way in static function OnWebSocketMessage(oMsg: WebSocketMessage) to get ip address and port for the incoming data?
In the attached picture I see oMsg can call other functions, but I do not know which one to call
I am using Fiddler Web Debugger (v4.6.2.2)
Related
System I have to update has http-handlers that are accessible via address like
http://<server>/handlers?name=some-handler-name
I added http form with action tag that directs to one of this handlers like this:
<form ... action="/handlers?name=some-handler-name" >
My form is a part of a system and located right on the same server. Basically its accessible via adress like
http://<server>/handlers?name=my-handler-with-form
But when I submit my form - nothing is posted to some-handler-name handler because my http-request receives code 302 (redirect).
Do I use correct address in action method (what I want is my form data to be posted to address like http://server/handlers?name=some-handler-name)?
Is it possible to post data to url that has query string parameters?
I guess that system intercept my postback and for some reason redirects it
Correct address is important
Yes, it is possible to post data with query params
There would be some redirect rule set at the server side. You would need to work with server side dev or read server side deployment/code documentation.
If I send a request with LWP, there is a convenience function as_string which tells me what request I just sent. Very handy, and in truth I have no problems with it. Except that I just noticed that it is surely lying to me. For instance, this code:
use v5.14.2;
use LWP;
my $response = LWP::UserAgent->new->get('http://user:pswd#example.com/');
say $response->request->as_string;
Gives this output
GET http://user:pswd#example.com/
User-Agent: libwww-perl/6.13
But surely the URL was not sent like that! The library must have parsed out the username and password, and added the appropriate headers, and added a host header, and so on. Is there an easy way to find out what was actually sent?
There's LWP::ConsoleLogger::Everywhere1, which you can just load to get all the details of both the request as well as the response. The request will be taken right before it's sent over the wire, and the response from when it comes back.
All you need to do is use LWP::ConsoleLogger::Everywhere anywhere in your code. If you want more control, the main module LWP::ConsoleLogger in that distribution will let you tweak settings easily.
However, this is not the real data that goes over the wire. If you want to know what it receives, you need to either monitor the connection with something like tcpdump and then take a look at it (which is quite advanced networking stuff), or maybe change the endpoint to your own IP address, or simply 127.0.0.1, and then use netcat to listen on a specific port.
$ nc -l 8080
If you send your request to that port, you'll see it in netcat.
1) Disclaimer: I'm a contributor for that module
Lets say I have the following:
subdomain: xyz.mydomain.com
my server's public DNS: xyz.fastserver.com
when someone goes to xyz.mydomain.com I want them to be redirected to
xyz.mydomain.com:8080
I have full access to all the typical A(host), C(NAME) as well as SRV records etc, tried different configurations but cant get it to work.
Any ideas?
You did not explicitly specify it, but I assume you mean HTTP (i.e. web browsing) and not FTP, SIP, SMTP... and lots of the other protocols on the internet.
In this case what you are trying to do is not possible. DNS A/AAAA/CNAME records are only used to get an IP address, so you can not get a port with these settings. And SRV records are not used within HTTP, so you can not use it to specify the port too.
Link to previous post that goes over the difference between redirect, rewrite, and vhosts.
DNS, however, has no concept of "port" unless you make a special record (SRV) and then a special request to get that record. It is much more transparent to use one of the HTTP methods described above.
I've installed and configured Prosody server. It listens on standard localhost:5222. Added admin in configuration file - user1#example.com. Every request to server ended up with error:
<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="" version="1.0">
<stream:error>
<not-well-formed xmlns="urn:ietf:params:xml:ns:xmpp-streams"/>
</stream:error>
</stream:stream>
As a client I would like to use strophe.js. I'm sending only presence stanza ($pres). Here is my code.
'use strict';
angular.module('xmppTestApp')
.controller('ChatCtrl', function () {
var vm = this;
var url = "http://localhost:5222";
var connection = null;
var output = document.getElementById("output");
function log(message) {
var line = document.createElement("div");
line.textContent = message;
output.appendChild(line);
}
function connectHandler(cond) {
if (cond == Strophe.Status.CONNECTED) {
log("connected");
connection.send($pres());
}
else {
log("not connected");
}
}
vm.connectB = function() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
console.info(url);
console.info(username);
console.info(password);
connection = new Strophe.Connection(url);
connection.connect(username, password, connectHandler);
}
});
In console i see error:
XMLHttpRequest cannot load http://localhost:5222/. No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:9000' is therefore not allowed access.
How can I add Access-Control-Allow-Origin' header to my request?
When I'm trying send request to localhost:5222 (without http) I'm getting:
XMLHttpRequest cannot load localhost:5222. Cross origin requests are only supported for HTTP.
And when I send it through websocket, I'm getting:
WebSocket connection to 'ws://localhost:5222/' failed: Error during WebSocket handshake: Unexpected response code: 200
Fiddler provides me protocol violation report:
The server didn't return properly-formatted HTTP Headers. Maybe missing altogether
(e.g. HTTP/0.9), maybe only \r\r instead of \r\n\r\n?
First and foremost, it looks like you're trying to connect directly to port 5222 (typically used for XMPP), but in order to use Strophe from a client-side webpage, you must use HTTP-Binding (aka BOSH).
XMPP vs BOSH
Strophe speaks XMPP, but it is unique in that it does not actually transmit data using the XMPP protocol, instead it relies on BOSH for this (that is, Bidirectional-streams Over Synchronous HTTP). This is because the XMPP protocol is designed to keep the client and server connected at all times, and we all know this isn't how HTTP works. To put it in simple terms, BOSH allows your HTTP client to asynchronously receive data without having to explicitly make a request for it. If you have more questions regarding BOSH let me know and I'll try my best to explain what is does and why you need it.
You must enable this feature in prosody before connecting with Strophe, check out this link to get setup.
Prosody Docs - Setting up BOSH
Once you've setup BOSH, you will need to change your client side code to use a different address. It is likely that you have setup the path+port for BOSH to something such as :5280/http-bind/. At this point you need to make sure that Strophe is using this URL instead of the actual XMPP port of 5222.
Finally, CORS is required for any resource outside of your websites domain and port. In your example, your client has to make a request to a URL which is running on a different port+domain as the page itself (the connection between Strophe and Prosody). Good news is, Prosody already supports CORS and enabling it is very straightforward. All of this is explained in much further detail on the page I linked earlier.
Hope that helps!
I'm doing a university project in which i have to communicate with an existing server using SIP messages. I have done the part where i send the message, and i see with wireshark that the server responded, but i don't know how to receive that message and interpret it.
I have created a class that composes a sip message, and then creates a UdpTransport to send the message. I fill all of the message headers manually before that.
udp_transport = new UdpTransport(0, this);
udp_transport.sendMessage(sip_message, new IpAddress(toAddress), 5060);
Now i wonder how to receive the message the server sends back.
The declaration of MjSip SipProvider class (i modeled mine after it, they both call UDPTransport) implements TransportListener and has a callback methond onReceivedMessage()
but i'm not sure how to make it listen. I need to listen on a specific port, that the user inputs in the UI before. Not really sure how this callback even works.
So, i just need something to listen for a response message, and that it calls my processReceivedMessage() method so i can extract information.