I want to stream to WebView inside a Anrdoid App.
My code is:
WebView cam = (WebView) findViewById(R.id.Cam);
cam.getSettings().setLoadWithOverviewMode(true);
cam.getSettings().setUseWideViewPort(true);
cam.getSettings().setBuiltInZoomControls(true);
cam.getSettings().setPluginState(WebSettings.PluginState.ON);
cam.getSettings().setPluginState(WebSettings.PluginState.ON);
cam.loadUrl("http://192.168.0.10");
It works in emulator but if I install the App at smartphone it doesnt work. I get an error
Header fields are too long for the server to interpret
How do get rid of this error?
Edit sdkconfig and increase CONFIG_HTTPD_MAX_REQ_HDR_LEN e.g. like this:
CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
The default is 512. Don't set it too high to avoid wasting RAM, remember that ESP32 doesn't have much RAM.
Also it's best to set the User-Agent header in your WebView, otherwise a system-default User-Agent will be used, which can be longer or shorter depending on the actual Android device.
cam.getSettings().setUserAgentString("Mozilla/5.0 (my app)");
The above might just fit within the default 512 bytes for the request length.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With