I want to ask you how can I trace all the 'http' traffic triggered by a simple Java standalone application.
I run under openjdk version "1.8.0_212".
This doesn't works for me:
-Djava.util.logging.config.file=<path_to_file>/logging.properties
In the logging.properties:
sun.net.www.protocol.http.HttpURLConnection.level = FINEST
You say it doesn't work, but you don't specify what's the behaviour you are getting. You get no logs at all? You get some log traces but not all you would expect?
Nevertheless, here are some shots in the dark:
Try this in the logging.properties file:
handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = ALL
sun.net.www.protocol.http.HttpURLConnection.level = ALL
In the java.util.logging.config.file property, make sure to specify the full path (and not a relative one) to the logging.properties file
I assume when you say http traffic you really mean http and not https; in case you want to debug SSL connections (https), try passing the following property to the JVM:
-Djavax.net.debug=all
If none of the above works, you may want to post a minimal, self contained example along with the full command line used to run it.
Related
I want to use elastic.apm.ignore_exceptions setting to ignore temporary logs from APM Agent when queue in APM Server is full or when APM Server is not working so it receive 503 error.
So exceptions from co.elastic.apm.agent.report.IntakeV2ReportingEventHandler
Based on doc:https://www.elastic.co/guide/en/apm/agent/java/master/config-core.html
I added elastic.apm.ignore_exceptions in elasticapm.properties, then as linux ENV, then as JAVA_OPT (-Delastic.apm.ignore_exceptions=co.elastic.apm.agent.report.IntakeV2ReportingEventHandler) but nothing changed.
During startup my application I can see
INFO co.elastic.apm.agent.configuration.StartupInfo - ignore_exceptions: 'co.elastic.apm.agent.report.IntakeV2ReportingEventHandler' (source:
but still I can se ERROR logs from IntakeV2ReportingEventHandler and still some functions in my app does not work because of that.
I use elastic-apm-java agent in 1.35 version
Can someone explain how this setting should work?
I am trying to use Fabric whith java shim and I am still searching how to display logs on the peer output ?
I tried this :
peer node start --logging-level DEBUG
also searching to use the logger of the parent class :
private static Log logger = LogFactory.getLog(ChaincodeBase.class);
without success. Cannot see the outputs on the peer
Does anyone has an idea ?
I found myself the solution. It implies to access the Docker image inside the peer and call :
docker logs mycontainersidwhatever
but i think is could be still buggy as I am in DEBUG mode, and I see now only WARN level for the chaincode
When you instantiate a new chaincode, the peer will create a new docker container called dev-(peer name)-(contract name)-(contract version). You can see logs direct in this container.
However, fabric java chaincode uses its own logging configuration, and it uses an environment variable called CORE_CHAINCODE_LOGGING_LEVEL to define the logging level the chaincode will use. Usually, this environment variable is set to 'info' level. You can manually update the value of this variable inside the docker container running the contract, or you can define this variable into the peer, so every contract will the the defined value to it.
In 'fabric-samples\first-network\base\peer-base.yaml' ensure you have the following before you start HLF network, and then spin up the network.
FABRIC_LOGGING_SPEC=DEBUG
This will generate logs in DEBUG mode. Now, in order to see these logs that are generated within docker contaner, we'll have to ask docker for logs, and that can be done using in a terminal window.
docker logs -f <<container-name>>
Use
docker logs container_name
Or inside your docker_compose.yaml, set logging environment
FABRIC_LOGGING_SPEC=DEBUG
Or else,
try setting up in you cli for one time use
export
I've installed the latest RabbitMQ server (rabbitmq-server-3.3.0-1.noarch.rpm) on a fresh Centos 5.10 VM according to the instructions on the official site.
I've done this many times before during development and never had any issues. However, this time I cannot log into the management web interface using the default guest/guest user.
In the logs, I see the following:
=ERROR REPORT==== 4-Apr-2014::00:55:15 ===
webmachine error: path="api/whoami"
"Unauthorized"
What could be causing this?
It's new features since the version 3.3.0
http://www.rabbitmq.com/release-notes/README-3.3.0.txt
server
------
...
25603 prevent access using the default guest/guest credentials except via
localhost.
If you want enable the guest user read this or this RabbitMQ 3.3.1 can not login with guest/guest
# remove guest from loopback_users in rabbitmq.config like this
[{rabbit, [{loopback_users, []}]}].
# It is danger for default user and default password for remote access
# better to change password
rabbitmqctl change_password guest NEWPASSWORD
If you want create a new user with admin grants:
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
Now you can access using test test.
If you still can't access the management console after a fresh install, check if the management console was enabled. To enable it:
Go to the RabbitMQ command prompt.
Type:
rabbitmq-plugins enable rabbitmq_management
Something that just happened to me and caused me some headaches:
I have set up a new Linux RabbitMQ server and used a shell script to set up my own custom users (not guest!).
The script had several of those "code" blocks:
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
Very similar to the one in Gabriele's answer, so I take his code and don't need to redact passwords.
Still I was not able to log in in the management console. Then I noticed that I had created the setup script in Windows (CR+LF line ending) and converted the file to Linux (LF only), then reran the setup script on my Linux server.
... and was still not able to log in, because it took another 15 minutes until I realized that calling add_user over and over again would not fix the broken passwords (which probably ended with a CR character). I had to call change_password for every user to fix my earlier mistake:
rabbitmqctl change_password test test
(Another solution would have been to delete all users and then call the script again)
If on Windows and installed using chocolatey make sure firewall is allowing the default ports for it:
netsh advfirewall firewall add rule name="RabbitMQ Management" dir=in action=allow protocol=TCP localport=15672
netsh advfirewall firewall add rule name="RabbitMQ" dir=in action=allow protocol=TCP localport=5672
for the remote access.
I also couldn't log in to Rabbit's web interface. in my case, cookies were disabled in the browser for this web interface. I allowed cookies to be saved and rebooted chrome. and I was able to log in again.
If you are in Mac OS, you need to open the /usr/local/etc/rabbitmq/rabbitmq-env.conf and
set NODE_IP_ADDRESS=, it used to be 127.0.0.1. Then add another user as the accepted answer suggested.
After that, restart rabbitMQ, brew services restart rabbitmq
I want to make some API calls to a server using HttpURLConnection. But the requests are not successful, returning:
<error>
<http_status>400 Bad Request</http_status>
<message>Unexpected request Content-Type header ''. Expecting 'application/x-www-form-urlencoded'.</message>
</error>
So I want to check what the "real" content is that is being sent to the server. By real content I mean the exact HTTP request.
Any ideas how I can see this?
Edit:
Based on the first answers here I should clarify my problem: I want to avoid using an external program like HTTP sniffer or anything and I was hoping that there is a function or a property or whatever that holds the information I am looking for.
If that is not the case, does someone know if this information can be manually rebuilt (for example by calling several functions like getRequestMethod(), etc.)
I am facing this problem kinda often so that it's worth the effort to build such functionality myself. Just need to know how :)
You can put the HttpURLConnection in debug mode by enabling java.logging with
-Djava.util.logging.config.file=logging.properties
and put in logging.properties (by default in JRE_HOME\lib) the following property
sun.net.www.protocol.http.HttpURLConnection.level = ALL
tcpdump will work, but it can be hard to make it do what you want. NetCat is more user-friendly (here's the project page: http://netcat.sourceforge.net/ - most Unix platforms already include it).
nc -l 9999
This will listen on TCP port 9999, and when an HTTP client connects, it'll print out the full text of the request.
The accepted solution did not work for me. But what did was
static {
ConsoleHandler handler = new ConsoleHandler();
handler.setLevel(Level.ALL);
Logger log = LogManager.getLogManager().getLogger("");
log.addHandler(handler);
log.setLevel(Level.ALL);
System.setProperty("javax.net.debug","all");
}
Use something like tcpdump, which can dump the actual network packets that are emitted or received by your computer.
On JDK 11 I was able to log all the http connections, setting java.util.logging.ConsoleHandler.level to FINEST and adding the following lines in the file logging.properties which is by default in %JAVA_HOME%/conf:
sun.net.www.protocol.http.HttpURLConnection.level = FINEST
sun.net.www.protocol.http.HttpURLConnection.handlers = java.util.logging.ConsoleHandler
I'm following Scott Davis' tutorials on developing grails apps, but whenever i try to run my app (or indeed his source code) i get "Firefox has detected that the server is redirecting the request for this address in a way that will never complete." Safari gives a similar error message as does Opera.
As i've tested the original authors source code which gives the same error i'm fairly confident it's nothing to do with the code.
Is this a problem with the web server on my machine? I use Mac OS Snow Leopard so i'm assuming it's apache that's generating this error.
Edit: Seems Grails as standard uses Jetty, so probably not Apache that is causing the problem. However also tested the app on Glassfish and i get the same error.
Anyone know what i can do to fix this?
Cheers
It depends on the code and Apache configuration you are using. I assume that the web server sends cyclic HTTP redirections, eg. from /root/ to /root (without the slash) and vice versa. This causes a redirection infinite loop.
Check your configuration on conditions that cause a HTTP redirect. For example, Apache automatically adds slashes to directory URLs in standard configuration (like the /root/ example above). I don't know Grails, so I cannot give you a hint on how URLs are processed within the app.
You can also use manual HTTP requests for debugging to see whats going on behind the scenes, using telnet on a terminal:
$ telnet localhost 80
GET / HTTP/1.0
I guess the response will be something like that:
HTTP/1.0 302 Found
Location: XXX
...
Now do a second request on the URL passed in the Location header and so on.
I was getting the same error a little while ago, heres how I fixed:
Try the same page on a different internet setup (it could be your ISP)
Open up Safari, Firefox or whatever your using and empty the cache and delete ALL your cookies
Reboot your computer and try again
It may work now, but if it doesn't:
open up Firefox and type 'about:config' (without the quotes) into the URL bar
You will get some little warning, just press OK
Type 'redirect' into the Filter box
You should see a listing for 'network.http.redirection-limit'
Double click the listing and type a large number (anything above 50 and lower than 200)
Press OK, quit and re-open FireFox
Basically all that does is make FireFox's tolerance for redirect loops higher which should fix your problem - but usually, just borrowing someone else's internet connection fixes it
Hope that all helps =)
Just carefully check your URLMappings configuration:
YOUR_APP/grails-app/conf/UrlMappings.groovy
Common case:
You configured request to be handled like this:
"/anything" (controller:"someController")
So without action, request will be handled by default one, "index". "index" action usually redirects to "list", and "list", in some cases redirect back to "index"
There is your loop.
Good luck