Popular New Releases in Proxy
frp
v0.41.0
shadowsocks-windows
4.4.1.0
v2ray-core
v4.31.0
caddy
v2.5.0-rc.1
XX-Net
v4.7.11 Performance improvement
Popular Libraries in Proxy
by fatedier go
55464 Apache-2.0
A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
by shadowsocks csharp
53806 GPL-3.0
A C# port of shadowsocks
by v2ray go
39387 MIT
A platform for building proxies to bypass network restrictions.
by caddyserver go
39075 Apache-2.0
Fast, multi-platform web server with automatic HTTPS
by XX-net python
31157
A proxy tool to bypass GFW.
by Dreamacro go
22790 GPL-3.0
A rule-based tunnel in Go.
by inconshreveable go
20741 NOASSERTION
Introspected tunnels to localhost
by ehang-io go
19999 GPL-3.0
一款轻量级、高性能、功能强大的内网穿透代理服务器。支持tcp、udp、socks5、http等几乎所有流量转发,可用来访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析、内网socks5代理等等……,并带有功能强大的web管理端。a lightweight, high-performance, powerful intranet penetration proxy server, with a powerful web management terminal.
by nginx-proxy python
15905 MIT
Automated nginx proxy for Docker containers using docker-gen
Trending New libraries in Proxy
by XTLS go
8099 MPL-2.0
Xray, Penetrates Everything. Also the best v2ray-core, with XTLS support. Fully compatible configuration.
by microsoft csharp
5209 MIT
A toolkit for developing high-performance HTTP reverse proxy applications.
by p4gefau1t go
4281 GPL-3.0
Go实现的Trojan代理,支持多路复用/路由功能/CDN中转/Shadowsocks混淆插件,多平台,无依赖。A Trojan proxy written in Go. An unidentifiable mechanism that helps you bypass GFW. https://p4gefau1t.github.io/trojan-go/
by proxysu csharp
3680 GPL-3.0
Xray,V2ray,Trojan,NaiveProxy, Trojan-Go, ShadowsocksR(SSR),Shadowsocks-libev及相关插件,MTProto+TLS 一键安装工具,windows下用(一键科学上网)
by SagerNet kotlin
3212 NOASSERTION
The universal proxy toolchain for Android
by HyNetwork go
1796 MIT
Hysteria is a feature-packed network utility optimized for networks of poor quality (e.g. satellite connections, congested public Wi-Fi, connecting from China to servers abroad)
by iann0036 go
1750 MIT
Generate an IAM policy from AWS calls using client-side monitoring (CSM) or embedded proxy
by projectdiscovery go
1566 MIT
Swiss Army knife Proxy tool for HTTP/HTTPS traffic capture, manipulation, and replay on the go.
by lwch go
1497 MIT
新一代主机管理工具
Top Authors in Proxy
1
13 Libraries
63
2
13 Libraries
139
3
10 Libraries
22
4
9 Libraries
12994
5
8 Libraries
556
6
7 Libraries
287
7
7 Libraries
5328
8
7 Libraries
105
9
7 Libraries
258
10
6 Libraries
80
1
13 Libraries
63
2
13 Libraries
139
3
10 Libraries
22
4
9 Libraries
12994
5
8 Libraries
556
6
7 Libraries
287
7
7 Libraries
5328
8
7 Libraries
105
9
7 Libraries
258
10
6 Libraries
80
Trending Kits in Proxy
No Trending Kits are available at this moment for Proxy
Trending Discussions on Proxy
Fixing git HTTPS Error: "bad key length" on macOS 12
Error: While updating laravel 8 to 9. Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Invalid options object. Dev Server has been initialized using an options object that does not match the API schema
Oracle 12c docker setup on Apple M1
package io/fs is not in GOROOT while building the go project
How to configure proxy in emulators in new versions of Android Studio?
Uvicorn async workers are still working synchronously
Fatal Android 12: Exception: startForegroundService() not allowed due to mAllowStartForeground false
Getting android.app.ForegroundServiceStartNotAllowedException in Android 12 (SDK 31)
"Theming Icons" functionality crashes live wallpapers on Android 12
QUESTION
Fixing git HTTPS Error: "bad key length" on macOS 12
Asked 2022-Mar-29 at 17:34I am using a company-hosted (Bitbucket) git repository that is accessible via HTTPS. Accessing it (e.g. git fetch
) worked using macOS 11 (Big Sur), but broke after an update to macOS 12 Monterey.
*
After the update of macOS to 12 Monterey my previous git setup broke. Now I am getting the following error message:
1$ git fetch
2fatal: unable to access 'https://.../':
3error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length
4
For what it's worth, using curl
does not work either:
1$ git fetch
2fatal: unable to access 'https://.../':
3error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length
4$ curl --insecure -L -v https://...
5* Trying ...
6* Connected to ... (...) port 443 (#0)
7* ALPN, offering h2
8* ALPN, offering http/1.1
9* successfully set certificate verify locations:
10* CAfile: /etc/ssl/cert.pem
11* CApath: none
12* TLSv1.2 (OUT), TLS handshake, Client hello (1):
13* TLSv1.2 (IN), TLS handshake, Server hello (2):
14* TLSv1.2 (IN), TLS handshake, Certificate (11):
15* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
16* TLSv1.2 (IN), TLS handshake, Server finished (14):
17* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
18* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
19* TLSv1.2 (OUT), TLS handshake, Finished (20):
20* error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length
21* Closing connection 0
22curl: (35) error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length
23
Accessing the same HTTPS-source via Safari or Firefox works.
As far as I understand, the underlying error "bad key length" error is coming from OpenSSL/LibreSSL, this would be consistent with both git and curl failing after an OS upgrade.
This is the output from openssl:
1$ git fetch
2fatal: unable to access 'https://.../':
3error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length
4$ curl --insecure -L -v https://...
5* Trying ...
6* Connected to ... (...) port 443 (#0)
7* ALPN, offering h2
8* ALPN, offering http/1.1
9* successfully set certificate verify locations:
10* CAfile: /etc/ssl/cert.pem
11* CApath: none
12* TLSv1.2 (OUT), TLS handshake, Client hello (1):
13* TLSv1.2 (IN), TLS handshake, Server hello (2):
14* TLSv1.2 (IN), TLS handshake, Certificate (11):
15* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
16* TLSv1.2 (IN), TLS handshake, Server finished (14):
17* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
18* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
19* TLSv1.2 (OUT), TLS handshake, Finished (20):
20* error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length
21* Closing connection 0
22curl: (35) error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length
23$ openssl s_client -servername ... -connect ...:443
24CONNECTED(00000005)
25depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root G2
26verify return:1
27depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = Thawte TLS RSA CA G1
28verify return:1
29depth=0 ...
304593010348:error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length:
31/System/Volumes/Data/SWE/macOS/BuildRoots/b8ff8433dc/Library/Caches/com.apple.xbs
32/Sources/libressl/libressl-75/libressl-2.8/crypto/apple/hmac/hmac.c:188:
33---
34Certificate chain
35 ...
36---
37No client certificate CA names sent
38Server Temp Key: DH, 2048 bits
39---
40SSL handshake has read 4105 bytes and written 318 bytes
41---
42New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-GCM-SHA384
43Server public key is 4096 bit
44Secure Renegotiation IS supported
45Compression: NONE
46Expansion: NONE
47No ALPN negotiated
48SSL-Session:
49 Protocol : TLSv1.2
50 Cipher : DHE-RSA-AES256-GCM-SHA384
51 Session-ID: 1FA062DC9EEC9A310FF8231F1EB11A3BD6E0778F7AB6E98EAD1020A44CF1A407
52 Session-ID-ctx:
53 Master-Key:
54 Start Time: 1635319904
55 Timeout : 7200 (sec)
56 Verify return code: 0 (ok)
57---
58
59
I did try to add the server's certificates into a custom pem file and setting http.sslCAInfo, but that didn't work. As a workaround, I am currently using a proxy that decrypts/re-encrypts HTTPS traffic.
How do I configure git (or all LibreSSL users) to accept the server's certificate?
ANSWER
Answered 2021-Nov-02 at 07:12Unfortunately I can't provide you with a fix, but I've found a workaround for that exact same problem (company-hosted bitbucket resulting in exact same error).
I also don't know exactly why the problem occurs, but my best guess would be that the libressl library shipped with Monterey has some sort of problem with specific (?TLSv1.3) certs. This guess is because the brew-installed openssl v1.1 and v3 don't throw that error when executed with /opt/homebrew/opt/openssl/bin/openssl s_client -connect ...:443
To get around that error, I've built git from source built against different openssl and curl implementations:
- install
autoconf
,openssl
andcurl
with brew (I think you can select the openssl lib you like, i.e. v1.1 or v3, I chose v3) - clone git version you like, i.e.
git clone --branch v2.33.1 https://github.com/git/git.git
cd git
make configure
(that is why autoconf is needed)- execute
LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/curl/lib" CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/opt/curl/include" ./configure --prefix=$HOME/git
(here LDFLAGS and CPPFLAGS include the libs git will be built against, the right flags are emitted by brew on install success of curl and openssl; --prefix is the install directory of git, defaults to/usr/local
but can be changed) make install
- ensure to add the install directory's subfolder
/bin
to the front of your$PATH
to "override" the default git shipped by Monterey - restart terminal
- check that
git version
shows the new version
This should help for now, but as I already said, this is only a workaround, hopefully Apple fixes their libressl fork ASAP.
QUESTION
Error: While updating laravel 8 to 9. Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Asked 2022-Mar-29 at 06:51Nothing to install, update or remove Generating optimized autoload files Class App\Helpers\Helper located in C:/wamp64/www/vuexylaravel/app\Helpers\helpers.php does not comply with psr-4 autoloading standard. Skipping. > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi
1 Error
2
3 Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL
4 at C:\wamp64\www\vuexylaravel\vendor\fideloper\proxy\config\trustedproxy.php:48
5 44▕ * - 'HEADER_X_FORWARDED_AWS_ELB' (If you are using AWS Elastic Load Balancer)
6 45▕ *
7 46▕ * @link https://symfony.com/doc/current/deployment/proxies.html
8 47▕ */
9 ➜ 48▕ 'headers' => Illuminate\Http\Request::HEADER_X_FORWARDED_ALL,
10 49▕
11 50▕ ];
12 51▕
13
14 1 C:\wamp64\www\vuexylaravel\vendor\laravel\framework\src\Illuminate\Support\ServiceProvider.php:138
15 require()
16
17 2 C:\wamp64\www\vuexylaravel\vendor\fideloper\proxy\src\TrustedProxyServiceProvider.php:28
18 Illuminate\Support\ServiceProvider::mergeConfigFrom("C:\wamp64\www\vuexylaravel\vendor\fideloper\proxy\config\trustedproxy.php", "trustedproxy")
19Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
20
ANSWER
Answered 2022-Feb-13 at 17:35If you are upgrading your Laravel 8 project to Laravel 9 by importing your existing application code into a totally new Laravel 9 application skeleton, you may need to update your application's "trusted proxy" middleware.
Within your app/Http/Middleware/TrustProxies.php file, update use Fideloper\Proxy\TrustProxies as Middleware to use Illuminate\Http\Middleware\TrustProxies as Middleware.
Next, within app/Http/Middleware/TrustProxies.php, you should update the $headers property definition:
// Before...
protected $headers = Request::HEADER_X_FORWARDED_ALL;
// After...
1 Error
2
3 Undefined constant Illuminate\Http\Request::HEADER_X_FORWARDED_ALL
4 at C:\wamp64\www\vuexylaravel\vendor\fideloper\proxy\config\trustedproxy.php:48
5 44▕ * - 'HEADER_X_FORWARDED_AWS_ELB' (If you are using AWS Elastic Load Balancer)
6 45▕ *
7 46▕ * @link https://symfony.com/doc/current/deployment/proxies.html
8 47▕ */
9 ➜ 48▕ 'headers' => Illuminate\Http\Request::HEADER_X_FORWARDED_ALL,
10 49▕
11 50▕ ];
12 51▕
13
14 1 C:\wamp64\www\vuexylaravel\vendor\laravel\framework\src\Illuminate\Support\ServiceProvider.php:138
15 require()
16
17 2 C:\wamp64\www\vuexylaravel\vendor\fideloper\proxy\src\TrustedProxyServiceProvider.php:28
18 Illuminate\Support\ServiceProvider::mergeConfigFrom("C:\wamp64\www\vuexylaravel\vendor\fideloper\proxy\config\trustedproxy.php", "trustedproxy")
19Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
20protected $headers =
21 Request::HEADER_X_FORWARDED_FOR |
22 Request::HEADER_X_FORWARDED_HOST |
23 Request::HEADER_X_FORWARDED_PORT |
24 Request::HEADER_X_FORWARDED_PROTO |
25 Request::HEADER_X_FORWARDED_AWS_ELB;
26
then run
composer update
Make sure you are using PHP 8.0
QUESTION
Invalid options object. Dev Server has been initialized using an options object that does not match the API schema
Asked 2022-Mar-28 at 21:08I have been stock on this error on my project when I add "proxy": "http://localhost:6000"
in my package.json.
This is the error response after yarn start.
Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.allowedHosts[0] should be a non-empty string. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
But everything is fine when I remove the "proxy": "http://localhost:6000"
.
This is on my package.json:
1{
2 "name": "client",
3 "version": "0.1.0",
4 "private": true,
5 "dependencies": {
6 "@material-ui/core": "^4.12.3",
7 "@testing-library/jest-dom": "^5.16.1",
8 "@testing-library/react": "^12.1.2",
9 "@testing-library/user-event": "^13.5.0",
10 "axios": "^0.24.0",
11 "moment": "^2.29.1",
12 "react": "^17.0.2",
13 "react-dom": "^17.0.2",
14 "react-file-base64": "^1.0.3",
15 "react-redux": "^7.2.6",
16 "react-scripts": "5.0.0",
17 "redux": "^4.1.2",
18 "redux-thunk": "^2.4.1",
19 "web-vitals": "^2.1.2"
20 },
21 "scripts": {
22 "start": "react-scripts start",
23 "build": "react-scripts build",
24 "test": "react-scripts test",
25 "eject": "react-scripts eject"
26 },
27 "eslintConfig": {
28 "extends": [
29 "react-app",
30 "react-app/jest"
31 ]
32 },
33 "browserslist": {
34 "production": [
35 ">0.2%",
36 "not dead",
37 "not op_mini all"
38 ],
39 "development": [
40 "last 1 chrome version",
41 "last 1 firefox version",
42 "last 1 safari version"
43 ]
44 },
45 "proxy": "http://localhost:6000"
46}
47
ANSWER
Answered 2021-Dec-19 at 16:06Here is a workaround. Delete "proxy": "http://localhost:6000". Install package http-proxy-middleware with command npm install http-proxy-middleware --save. Create a file setupProxy.js inside your src folder. Add these lines inside:
1{
2 "name": "client",
3 "version": "0.1.0",
4 "private": true,
5 "dependencies": {
6 "@material-ui/core": "^4.12.3",
7 "@testing-library/jest-dom": "^5.16.1",
8 "@testing-library/react": "^12.1.2",
9 "@testing-library/user-event": "^13.5.0",
10 "axios": "^0.24.0",
11 "moment": "^2.29.1",
12 "react": "^17.0.2",
13 "react-dom": "^17.0.2",
14 "react-file-base64": "^1.0.3",
15 "react-redux": "^7.2.6",
16 "react-scripts": "5.0.0",
17 "redux": "^4.1.2",
18 "redux-thunk": "^2.4.1",
19 "web-vitals": "^2.1.2"
20 },
21 "scripts": {
22 "start": "react-scripts start",
23 "build": "react-scripts build",
24 "test": "react-scripts test",
25 "eject": "react-scripts eject"
26 },
27 "eslintConfig": {
28 "extends": [
29 "react-app",
30 "react-app/jest"
31 ]
32 },
33 "browserslist": {
34 "production": [
35 ">0.2%",
36 "not dead",
37 "not op_mini all"
38 ],
39 "development": [
40 "last 1 chrome version",
41 "last 1 firefox version",
42 "last 1 safari version"
43 ]
44 },
45 "proxy": "http://localhost:6000"
46}
47const { createProxyMiddleware } = require('http-proxy-middleware');
48
49module.exports = function(app) {
50 app.use(
51 '/api',
52 createProxyMiddleware({
53 target: 'http://localhost:6000',
54 changeOrigin: true,
55 })
56 );
57};
58
Now, run your app. It should work.
QUESTION
Oracle 12c docker setup on Apple M1
Asked 2022-Mar-21 at 09:52I am trying to run Oracle db in docker on M1 Mac. I have tried images from both store/oracle/database-enterprise:12.2.0.1-slim
and container-registry.oracle.com/database/enterprise:12.2.0.1-slim
but getting the same error.
docker run -d -it --name oracle -v $(pwd)/db/oradata:/ORCL store/oracle/database-enterprise:12.2.0.1-slim
I also tried non-slim version and by providing the --platform linux/amd64
to the docker command. Result is same.
Here's the result of docker logs -f oracle
1Setup Oracle Database
2Oracle Database 12.2.0.1 Setup
3Sat Jul 31 18:44:14 UTC 2021
4
5Check parameters ......
6log file is : /home/oracle/setup/log/paramChk.log
7paramChk.sh is done at 1 sec
8
9untar DB bits ......
10log file is : /home/oracle/setup/log/untarDB.log
11untarDB.sh is done at 29 sec
12
13config DB ......
14log file is : /home/oracle/setup/log/configDB.log
15Sat Jul 31 18:44:42 UTC 2021
16Start Docker DB configuration
17Call configDBora.sh to configure database
18Sat Jul 31 18:44:42 UTC 2021
19Configure DB as oracle user
20Setup Database directories ...
21
22SQL*Plus: Release 12.2.0.1.0 Production on Sat Jul 31 18:44:43 2021
23
24Copyright (c) 1982, 2016, Oracle. All rights reserved.
25
26ERROR:
27ORA-12547: TNS:lost contact
28
29
30Enter user-name: SP2-0306: Invalid option.
31Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
32where <logon> ::= <username>[/<password>][@<connect_identifier>]
33 <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
34Enter user-name: Enter password:
35ERROR:
36ORA-12547: TNS:lost contact
37
38
39SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
40update password
41
42Enter password for SYS:
43create pdb : ORCLPDB1
44
45SQL*Plus: Release 12.2.0.1.0 Production on Sat Jul 31 18:44:43 2021
46
47Copyright (c) 1982, 2016, Oracle. All rights reserved.
48
49ERROR:
50ORA-12547: TNS:lost contact
51
52
53Enter user-name: SP2-0306: Invalid option.
54Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
55where <logon> ::= <username>[/<password>][@<connect_identifier>]
56 <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
57Enter user-name: SP2-0306: Invalid option.
58Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
59where <logon> ::= <username>[/<password>][@<connect_identifier>]
60 <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
61SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
62Reset Database parameters
63
64SQL*Plus: Release 12.2.0.1.0 Production on Sat Jul 31 18:44:43 2021
65
66Copyright (c) 1982, 2016, Oracle. All rights reserved.
67
68ERROR:
69ORA-12547: TNS:lost contact
70
71
72Enter user-name: SP2-0306: Invalid option.
73Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
74where <logon> ::= <username>[/<password>][@<connect_identifier>]
75 <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
76Enter user-name: Enter password:
77ERROR:
78ORA-12547: TNS:lost contact
79
80
81SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
82
83LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 31-JUL-2021 18:44:44
84
85Copyright (c) 1991, 2016, Oracle. All rights reserved.
86
87Starting /u01/app/oracle/product/12.2.0/dbhome_1/bin/tnslsnr: please wait...
88
89TNSLSNR for Linux: Version 12.2.0.1.0 - Production
90System parameter file is /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora
91Log messages written to /u01/app/oracle/diag/tnslsnr/989db909d8df/listener/alert/log.xml
92Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
93Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
94
95Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1521)))
96STATUS of the LISTENER
97------------------------
98Alias LISTENER
99Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
100Start Date 31-JUL-2021 18:44:44
101Uptime 0 days 0 hr. 0 min. 0 sec
102Trace Level off
103Security ON: Local OS Authentication
104SNMP OFF
105Listener Parameter File /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora
106Listener Log File /u01/app/oracle/diag/tnslsnr/989db909d8df/listener/alert/log.xml
107Listening Endpoints Summary...
108 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
109 (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
110The listener supports no services
111The command completed successfully
112
113DONE!
114Remove password info
115Docker DB configuration is complete !
116ERROR : config DB failed, please check log /home/oracle/setup/log/configDB.log for details!
117OS process OFSD (ospid 188) idle for 30 seconds, exiting
1182017-08-09T10:36:20.752530+00:00
119ARCH: Archival disabled due to shutdown: 1090
120Shutting down archive processes
121Archiving is disabled
122JIT: pid 563 requesting stop
1232017-08-09T10:36:20.815635+00:00
124Stopping background process VKTM
1252017-08-09T10:36:26.581058+00:00
126Instance shutdown complete (OS id: 563)
127/usr/bin/tail: inotify cannot be used, reverting to polling: Function not implemented
128
Is it the issue with M1 or I my configuration
ANSWER
Answered 2021-Aug-04 at 20:48There are two issues here:
- Oracle Database is not supported on ARM processors, only Intel. See here: https://github.com/oracle/docker-images/issues/1814
- Oracle Database Docker images are only supported with Oracle Linux 7 or Red Hat Enterprise Linux 7 as the host OS. See here: https://github.com/oracle/docker-images/tree/main/OracleDatabase/SingleInstance
Oracle Database ... is supported for Oracle Linux 7 and Red Hat Enterprise Linux (RHEL) 7. For more details please see My Oracle Support note: Oracle Support for Database Running on Docker (Doc ID 2216342.1)
The referenced My Oracle Support Doc ID goes on to say that the database binaries in their Docker image are built specifically for Oracle Linux hosts, and will also work on Red Hat. That's it.
Because Docker provides process level virtualization it still pulls kernel and other OS libraries from the underlying host OS. A Docker image built for Oracle Linux needs an Oracle Linux host; it doesn't bring the Oracle Linux OS with it. Only Oracle Linux or Red Hat Linux are supported for any Oracle database Linux installation, with or without Docker. Ubuntu, Mac OS, Debian, or any other *NIX flavor will not provide predictable reliable results, even if it is hacked into working or the processes appear to work normally.
QUESTION
package io/fs is not in GOROOT while building the go project
Asked 2022-Mar-14 at 19:15I don't have much experience in go but I have been tasked to execute a go project :)
So i need to build the go project and then execute it
Below is the error when i build the go project. Seems to be some dependency(package and io/fs) is missing
1transform/transform.go:13:2: package embed is not in GOROOT (/usr/local/Cellar/go/1.15.8/libexec/src/embed)
2pkg/util/fs.go:4:2: package io/fs is not in GOROOT (/usr/local/Cellar/go/1.15.8/libexec/src/io/fs)
3
my go env
1transform/transform.go:13:2: package embed is not in GOROOT (/usr/local/Cellar/go/1.15.8/libexec/src/embed)
2pkg/util/fs.go:4:2: package io/fs is not in GOROOT (/usr/local/Cellar/go/1.15.8/libexec/src/io/fs)
3GO111MODULE="on"
4GOARCH="amd64"
5GOBIN=""
6GOCACHE="/Users/<XXXXX>/Library/Caches/go-build"
7GOENV="/Users/<XXXXX>/Library/Application Support/go/env"
8GOEXE=""
9GOFLAGS=""
10GOHOSTARCH="amd64"
11GOHOSTOS="darwin"
12GOINSECURE=""
13GOMODCACHE="/Users/<XXXXX>/go/pkg/mod"
14GONOPROXY=""
15GONOSUMDB=""
16GOOS="darwin"
17GOPATH="/Users/<XXXXX>/go"
18GOPRIVATE=""
19GOPROXY="https://proxy.golang.org,direct"
20GOROOT="/usr/local/Cellar/go/1.15.8/libexec"
21GOSUMDB="sum.golang.org"
22GOTMPDIR=""
23GOTOOLDIR="/usr/local/Cellar/go/1.15.8/libexec/pkg/tool/darwin_amd64"
24GCCGO="gccgo"
25AR="ar"
26CC="clang"
27CXX="clang++"
28CGO_ENABLED="1"
29GOMOD="/Users/<location to the project>/go.mod"
30CGO_CFLAGS="-g -O2"
31CGO_CPPFLAGS=""
32CGO_CXXFLAGS="-g -O2"
33CGO_FFLAGS="-g -O2"
34CGO_LDFLAGS="-g -O2"
35PKG_CONFIG="pkg-config"
36GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/5h/9qptf0sx3c12226jnqt75q8r0000gp/T/go-build648466970=/tmp/go-build -gno-record-gcc-switches -fno-common"
37
ANSWER
Answered 2021-Aug-12 at 05:56This package requires go v1.16, please upgrade your go version or use the appropriate docker builder.
QUESTION
How to configure proxy in emulators in new versions of Android Studio?
Asked 2022-Feb-23 at 14:14I need to configure the proxy manually in my emulator through Android Studio. From the official Android documentation, it is suggested that this change can be made in the "settings" tab of the emulator's extended controls. The problem is that it seems to me that this documentation is outdated, as this setting is no longer displayed in the "settings" tab of the Android Studio emulators' extended controls.
Documentation My Android Studio My version of Android Studio1Android Studio Bumblebee | 2021.1.1
2Build #AI-211.7628.21.2111.8092744, built on January 19, 2022
3Runtime version: 11.0.11+9-b60-7590822 amd64
4VM: OpenJDK 64-Bit Server VM by Oracle Corporation
5Windows 10 10.0
6GC: G1 Young Generation, G1 Old Generation
7Memory: 1280M
8Cores: 8
9Registry: external.system.auto.import.disabled=true
10Non-Bundled Plugins: com.wakatime.intellij.plugin (13.1.10), wu.seal.tool.jsontokotlin (3.7.2), org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40), com.developerphil.adbidea (1.6.4), org.jetbrains.compose.desktop.ide (1.0.0), ru.adelf.idea.dotenv (2021.2), org.intellij.plugins.markdown (211.7142.37)
11
ANSWER
Answered 2022-Feb-17 at 19:12After a while trying to find solutions to this problem, I saw that an emulator running outside android studio provides these options. To run a standalone Android Studio emulator see the official documentation or simply enter the command:
1Android Studio Bumblebee | 2021.1.1
2Build #AI-211.7628.21.2111.8092744, built on January 19, 2022
3Runtime version: 11.0.11+9-b60-7590822 amd64
4VM: OpenJDK 64-Bit Server VM by Oracle Corporation
5Windows 10 10.0
6GC: G1 Young Generation, G1 Old Generation
7Memory: 1280M
8Cores: 8
9Registry: external.system.auto.import.disabled=true
10Non-Bundled Plugins: com.wakatime.intellij.plugin (13.1.10), wu.seal.tool.jsontokotlin (3.7.2), org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40), com.developerphil.adbidea (1.6.4), org.jetbrains.compose.desktop.ide (1.0.0), ru.adelf.idea.dotenv (2021.2), org.intellij.plugins.markdown (211.7142.37)
11emulator -avd <avd_name>
12
In my case I'm using an avd named PIXEL 4 API 30
, so the command will be emulator -avd PIXEL_4_API_30
. If you are on Windows you may have problems running this command so I suggest you see this.
The solution proposed by @Inliner also solves this problem.
QUESTION
Uvicorn async workers are still working synchronously
Asked 2022-Feb-07 at 18:39Question in short
I have migrated my project from Django 2.2 to Django 3.2, and now I want to start using the possibility for asynchronous views. I have created an async view, setup asgi configuration, and run gunicorn with a Uvicorn worker. When swarming this server with 10 users concurrently, they are served synchronously. What do I need to configure in order to serve 10 concurrent users an async view?
Question in detail
This is what I did so far in my local environment:
- I am working with Django 3.2.10 and Python 3.9.
- I have installed
gunicorn
anduvicorn
through pip - I have created an
asgi.py
file with the following contents
1 import os
2 from django.core.asgi import get_asgi_application
3 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MyService.settings.local')
4 application = get_asgi_application()
5
- I have created a view with the following implementation, and connected it in
urlpatterns
:
1 import os
2 from django.core.asgi import get_asgi_application
3 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MyService.settings.local')
4 application = get_asgi_application()
5 import asyncio
6 import json
7 from django.http import HttpResponse
8
9 async def async_sleep(request):
10 await asyncio.sleep(1)
11 return HttpResponse(json.dumps({'mode': 'async', 'time': 1).encode())
12
- I run locally a gunicorn server with a Uvicorn worker:
1 import os
2 from django.core.asgi import get_asgi_application
3 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MyService.settings.local')
4 application = get_asgi_application()
5 import asyncio
6 import json
7 from django.http import HttpResponse
8
9 async def async_sleep(request):
10 await asyncio.sleep(1)
11 return HttpResponse(json.dumps({'mode': 'async', 'time': 1).encode())
12gunicorn MyService.asgi:application -k uvicorn.workers.UvicornWorker
13[2022-01-26 14:37:14 +0100] [8732] [INFO] Starting gunicorn 20.1.0
14[2022-01-26 14:37:14 +0100] [8732] [INFO] Listening at: http://127.0.0.1:8000 (8732)
15[2022-01-26 14:37:14 +0100] [8732] [INFO] Using worker: uvicorn.workers.UvicornWorker
16[2022-01-26 14:37:14 +0100] [8733] [INFO] Booting worker with pid: 8733
17[2022-01-26 13:37:15 +0000] [8733] [INFO] Started server process [8733]
18[2022-01-26 13:37:15 +0000] [8733] [INFO] Waiting for application startup.
19[2022-01-26 13:37:15 +0000] [8733] [INFO] ASGI 'lifespan' protocol appears unsupported.
20[2022-01-26 13:37:15 +0000] [8733] [INFO] Application startup complete.
21
- I hit the API from a local client once. After 1 second, I get a 200 OK, as expected.
- I set up a locust server to spawn concurrent users. When I let it make requests with 1 concurrent user, every 1 second an API call is completed.
- When I let it make requests with 10 concurrent users, every 1 second an API call is completed. All other requests are waiting.
This last thing is not what I expect. I expect the worker, while sleeping asynchronously, to pick up the next request already. Am I missing some configuration?
I also tried it by using Daphne instead of Uvicorn, but with the same result.
Locust
This is how I have set up my locust.
- Start a new virtualenv
pip install locust
- Create a
locustfile.py
with the following content:
1 import os
2 from django.core.asgi import get_asgi_application
3 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MyService.settings.local')
4 application = get_asgi_application()
5 import asyncio
6 import json
7 from django.http import HttpResponse
8
9 async def async_sleep(request):
10 await asyncio.sleep(1)
11 return HttpResponse(json.dumps({'mode': 'async', 'time': 1).encode())
12gunicorn MyService.asgi:application -k uvicorn.workers.UvicornWorker
13[2022-01-26 14:37:14 +0100] [8732] [INFO] Starting gunicorn 20.1.0
14[2022-01-26 14:37:14 +0100] [8732] [INFO] Listening at: http://127.0.0.1:8000 (8732)
15[2022-01-26 14:37:14 +0100] [8732] [INFO] Using worker: uvicorn.workers.UvicornWorker
16[2022-01-26 14:37:14 +0100] [8733] [INFO] Booting worker with pid: 8733
17[2022-01-26 13:37:15 +0000] [8733] [INFO] Started server process [8733]
18[2022-01-26 13:37:15 +0000] [8733] [INFO] Waiting for application startup.
19[2022-01-26 13:37:15 +0000] [8733] [INFO] ASGI 'lifespan' protocol appears unsupported.
20[2022-01-26 13:37:15 +0000] [8733] [INFO] Application startup complete.
21from locust import HttpUser, task
22class SleepUser(HttpUser):
23 @task
24 def async_sleep(self):
25 self.client.get('/api/async_sleep/')
26
- Run the locust executable from the shell
- Visit http://0.0.0.0:8089 in the browser
- Set number of workers to 10, spawn rate to 1 and host to http://127.0.0.1:8000
Middleware
These are my middleware settings
1 import os
2 from django.core.asgi import get_asgi_application
3 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MyService.settings.local')
4 application = get_asgi_application()
5 import asyncio
6 import json
7 from django.http import HttpResponse
8
9 async def async_sleep(request):
10 await asyncio.sleep(1)
11 return HttpResponse(json.dumps({'mode': 'async', 'time': 1).encode())
12gunicorn MyService.asgi:application -k uvicorn.workers.UvicornWorker
13[2022-01-26 14:37:14 +0100] [8732] [INFO] Starting gunicorn 20.1.0
14[2022-01-26 14:37:14 +0100] [8732] [INFO] Listening at: http://127.0.0.1:8000 (8732)
15[2022-01-26 14:37:14 +0100] [8732] [INFO] Using worker: uvicorn.workers.UvicornWorker
16[2022-01-26 14:37:14 +0100] [8733] [INFO] Booting worker with pid: 8733
17[2022-01-26 13:37:15 +0000] [8733] [INFO] Started server process [8733]
18[2022-01-26 13:37:15 +0000] [8733] [INFO] Waiting for application startup.
19[2022-01-26 13:37:15 +0000] [8733] [INFO] ASGI 'lifespan' protocol appears unsupported.
20[2022-01-26 13:37:15 +0000] [8733] [INFO] Application startup complete.
21from locust import HttpUser, task
22class SleepUser(HttpUser):
23 @task
24 def async_sleep(self):
25 self.client.get('/api/async_sleep/')
26MIDDLEWARE = [
27 'django_prometheus.middleware.PrometheusBeforeMiddleware',
28 'corsheaders.middleware.CorsMiddleware',
29 'django.middleware.gzip.GZipMiddleware',
30 'django.contrib.sessions.middleware.SessionMiddleware',
31 'django.middleware.common.CommonMiddleware',
32 'django.middleware.csrf.CsrfViewMiddleware',
33 'django.contrib.auth.middleware.AuthenticationMiddleware',
34 'django.contrib.messages.middleware.MessageMiddleware',
35 'django.middleware.clickjacking.XFrameOptionsMiddleware',
36 'django.middleware.security.SecurityMiddleware',
37 'shared.common.middleware.ApiLoggerMiddleware',
38 'django_prometheus.middleware.PrometheusAfterMiddleware',
39]
40
The ApiLoggerMiddleware from shared is from our own code, I will investigate this one first. This is the implementation of it.
1 import os
2 from django.core.asgi import get_asgi_application
3 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MyService.settings.local')
4 application = get_asgi_application()
5 import asyncio
6 import json
7 from django.http import HttpResponse
8
9 async def async_sleep(request):
10 await asyncio.sleep(1)
11 return HttpResponse(json.dumps({'mode': 'async', 'time': 1).encode())
12gunicorn MyService.asgi:application -k uvicorn.workers.UvicornWorker
13[2022-01-26 14:37:14 +0100] [8732] [INFO] Starting gunicorn 20.1.0
14[2022-01-26 14:37:14 +0100] [8732] [INFO] Listening at: http://127.0.0.1:8000 (8732)
15[2022-01-26 14:37:14 +0100] [8732] [INFO] Using worker: uvicorn.workers.UvicornWorker
16[2022-01-26 14:37:14 +0100] [8733] [INFO] Booting worker with pid: 8733
17[2022-01-26 13:37:15 +0000] [8733] [INFO] Started server process [8733]
18[2022-01-26 13:37:15 +0000] [8733] [INFO] Waiting for application startup.
19[2022-01-26 13:37:15 +0000] [8733] [INFO] ASGI 'lifespan' protocol appears unsupported.
20[2022-01-26 13:37:15 +0000] [8733] [INFO] Application startup complete.
21from locust import HttpUser, task
22class SleepUser(HttpUser):
23 @task
24 def async_sleep(self):
25 self.client.get('/api/async_sleep/')
26MIDDLEWARE = [
27 'django_prometheus.middleware.PrometheusBeforeMiddleware',
28 'corsheaders.middleware.CorsMiddleware',
29 'django.middleware.gzip.GZipMiddleware',
30 'django.contrib.sessions.middleware.SessionMiddleware',
31 'django.middleware.common.CommonMiddleware',
32 'django.middleware.csrf.CsrfViewMiddleware',
33 'django.contrib.auth.middleware.AuthenticationMiddleware',
34 'django.contrib.messages.middleware.MessageMiddleware',
35 'django.middleware.clickjacking.XFrameOptionsMiddleware',
36 'django.middleware.security.SecurityMiddleware',
37 'shared.common.middleware.ApiLoggerMiddleware',
38 'django_prometheus.middleware.PrometheusAfterMiddleware',
39]
40import logging
41import os
42from typing import List
43
44from django.http import HttpRequest, HttpResponse
45from django.utils import timezone
46
47from shared.common.authentication_service import BaseAuthenticationService
48
49
50class ApiLoggerMiddleware:
51 TOO_BIG_FOR_LOG_BYTES = 2 * 1024
52
53 def __init__(self, get_response):
54 # The get_response callable is provided by Django, it is a function
55 # that takes a request and returns a response. Plainly put, once we're
56 # done with the incoming request, we need to pass it along to get the
57 # response which we need to ultimately return.
58 self._get_response = get_response
59 self.logger = logging.getLogger('api')
60 self.pid = os.getpid()
61 self.request_time = None
62 self.response_time = None
63
64 def __call__(self, request: HttpRequest) -> HttpResponse:
65 common_data = self.on_request(request)
66 response = self._get_response(request)
67 self.on_response(response, common_data)
68 return response
69
70 def truncate_body(self, request: HttpRequest) -> str:
71 return f"{request.body[:self.TOO_BIG_FOR_LOG_BYTES]}"
72
73 def on_request(self, request: HttpRequest) -> List[str]:
74 self.request_time = timezone.now()
75
76 remote_address = self.get_remote_address(request)
77 user_agent = request.headers.get('User-Agent') or ''
78 customer_uuid = self.get_customer_from_request_auth(request)
79 method = request.method
80 uri = request.get_raw_uri()
81
82 common = [
83 remote_address,
84 user_agent,
85 customer_uuid,
86 method,
87 uri
88 ]
89
90 in_line = [
91 "IN",
92 str(self.pid),
93 str(self.request_time),
94 ] + common + [
95 self.truncate_body(request)
96 ]
97
98 self.logger.info(', '.join(in_line))
99 return common
100
101 def on_response(self, response: HttpResponse, common: List[str]) -> None:
102 self.response_time = timezone.now()
103
104 out_line = [
105 "OUT",
106 str(self.pid),
107 str(self.response_time)
108 ] + common + [
109 str(self.response_time - self.request_time),
110 str(response.status_code),
111 ]
112 self.logger.info(", ".join(out_line))
113
114 @classmethod
115 def get_customer_from_request_auth(cls, request: HttpRequest) -> str:
116 token = request.headers.get('Authorization')
117 if not token:
118 return 'no token'
119 try:
120 payload = BaseAuthenticationService.validate_access_token(token)
121 return payload.get('amsOrganizationId', '')
122 except Exception:
123 return 'unknown'
124
125 @classmethod
126 def get_remote_address(cls, request: HttpRequest) -> str:
127 if 'X-Forwarded-For' in request.headers:
128 # in case the request comes in through a proxy, the remote address
129 # will be just the last proxy that passed it along, that's why we
130 # have to get the remote from X-Forwarded-For
131 # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
132 addresses = request.headers['X-Forwarded-For'].split(',')
133 client = addresses[0]
134 return client
135 else:
136 return request.META.get('REMOTE_ADDR', '')
137
Sources
Sources I have used:
ANSWER
Answered 2022-Feb-06 at 21:43When running the gunicorn
command, you can try to add workers
parameter with using options -w
or --workers
.
It defaults to 1
as stated in the gunicorn documentation. You may want to try to increase that value.
Example usage:
1 import os
2 from django.core.asgi import get_asgi_application
3 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'MyService.settings.local')
4 application = get_asgi_application()
5 import asyncio
6 import json
7 from django.http import HttpResponse
8
9 async def async_sleep(request):
10 await asyncio.sleep(1)
11 return HttpResponse(json.dumps({'mode': 'async', 'time': 1).encode())
12gunicorn MyService.asgi:application -k uvicorn.workers.UvicornWorker
13[2022-01-26 14:37:14 +0100] [8732] [INFO] Starting gunicorn 20.1.0
14[2022-01-26 14:37:14 +0100] [8732] [INFO] Listening at: http://127.0.0.1:8000 (8732)
15[2022-01-26 14:37:14 +0100] [8732] [INFO] Using worker: uvicorn.workers.UvicornWorker
16[2022-01-26 14:37:14 +0100] [8733] [INFO] Booting worker with pid: 8733
17[2022-01-26 13:37:15 +0000] [8733] [INFO] Started server process [8733]
18[2022-01-26 13:37:15 +0000] [8733] [INFO] Waiting for application startup.
19[2022-01-26 13:37:15 +0000] [8733] [INFO] ASGI 'lifespan' protocol appears unsupported.
20[2022-01-26 13:37:15 +0000] [8733] [INFO] Application startup complete.
21from locust import HttpUser, task
22class SleepUser(HttpUser):
23 @task
24 def async_sleep(self):
25 self.client.get('/api/async_sleep/')
26MIDDLEWARE = [
27 'django_prometheus.middleware.PrometheusBeforeMiddleware',
28 'corsheaders.middleware.CorsMiddleware',
29 'django.middleware.gzip.GZipMiddleware',
30 'django.contrib.sessions.middleware.SessionMiddleware',
31 'django.middleware.common.CommonMiddleware',
32 'django.middleware.csrf.CsrfViewMiddleware',
33 'django.contrib.auth.middleware.AuthenticationMiddleware',
34 'django.contrib.messages.middleware.MessageMiddleware',
35 'django.middleware.clickjacking.XFrameOptionsMiddleware',
36 'django.middleware.security.SecurityMiddleware',
37 'shared.common.middleware.ApiLoggerMiddleware',
38 'django_prometheus.middleware.PrometheusAfterMiddleware',
39]
40import logging
41import os
42from typing import List
43
44from django.http import HttpRequest, HttpResponse
45from django.utils import timezone
46
47from shared.common.authentication_service import BaseAuthenticationService
48
49
50class ApiLoggerMiddleware:
51 TOO_BIG_FOR_LOG_BYTES = 2 * 1024
52
53 def __init__(self, get_response):
54 # The get_response callable is provided by Django, it is a function
55 # that takes a request and returns a response. Plainly put, once we're
56 # done with the incoming request, we need to pass it along to get the
57 # response which we need to ultimately return.
58 self._get_response = get_response
59 self.logger = logging.getLogger('api')
60 self.pid = os.getpid()
61 self.request_time = None
62 self.response_time = None
63
64 def __call__(self, request: HttpRequest) -> HttpResponse:
65 common_data = self.on_request(request)
66 response = self._get_response(request)
67 self.on_response(response, common_data)
68 return response
69
70 def truncate_body(self, request: HttpRequest) -> str:
71 return f"{request.body[:self.TOO_BIG_FOR_LOG_BYTES]}"
72
73 def on_request(self, request: HttpRequest) -> List[str]:
74 self.request_time = timezone.now()
75
76 remote_address = self.get_remote_address(request)
77 user_agent = request.headers.get('User-Agent') or ''
78 customer_uuid = self.get_customer_from_request_auth(request)
79 method = request.method
80 uri = request.get_raw_uri()
81
82 common = [
83 remote_address,
84 user_agent,
85 customer_uuid,
86 method,
87 uri
88 ]
89
90 in_line = [
91 "IN",
92 str(self.pid),
93 str(self.request_time),
94 ] + common + [
95 self.truncate_body(request)
96 ]
97
98 self.logger.info(', '.join(in_line))
99 return common
100
101 def on_response(self, response: HttpResponse, common: List[str]) -> None:
102 self.response_time = timezone.now()
103
104 out_line = [
105 "OUT",
106 str(self.pid),
107 str(self.response_time)
108 ] + common + [
109 str(self.response_time - self.request_time),
110 str(response.status_code),
111 ]
112 self.logger.info(", ".join(out_line))
113
114 @classmethod
115 def get_customer_from_request_auth(cls, request: HttpRequest) -> str:
116 token = request.headers.get('Authorization')
117 if not token:
118 return 'no token'
119 try:
120 payload = BaseAuthenticationService.validate_access_token(token)
121 return payload.get('amsOrganizationId', '')
122 except Exception:
123 return 'unknown'
124
125 @classmethod
126 def get_remote_address(cls, request: HttpRequest) -> str:
127 if 'X-Forwarded-For' in request.headers:
128 # in case the request comes in through a proxy, the remote address
129 # will be just the last proxy that passed it along, that's why we
130 # have to get the remote from X-Forwarded-For
131 # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
132 addresses = request.headers['X-Forwarded-For'].split(',')
133 client = addresses[0]
134 return client
135 else:
136 return request.META.get('REMOTE_ADDR', '')
137gunicorn MyService.asgi:application -k uvicorn.workers.UvicornWorker -w 10
138
Also, you may need to check other worker attributes in the documentation such as worker_class
and threads
QUESTION
Fatal Android 12: Exception: startForegroundService() not allowed due to mAllowStartForeground false
Asked 2022-Jan-11 at 12:43I noticed one exception (Firebase Crashlytics) for Pixel 5 and Pixel 4a (both on Android 12), no other devices, happened only two times, one time for each device.
What does it mean? Android 11 and 12 have the same rules for working with foreground services, but there are no issues with Android 11. Is this a bug of Pixel?
From Firebase Crashlytics:
1Fatal Exception: android.app.ForegroundServiceStartNotAllowedException
2startForegroundService() not allowed due to mAllowStartForeground false: service com.helge.droiddashcam/.service.RecorderService
3
4android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:54)
5androidx.core.content.ContextCompat.startForegroundService (ContextCompat.java:6)
6MyAppPackageHidden.service.RecorderService$Companion.startService (RecorderService.java:2)
7MyAppPackageHidden.ui.rec.RecActivity$getConnectionRecorderService$1.onServiceConnected (RecActivity.java:4)
8android.app.LoadedApk$ServiceDispatcher.doConnected (LoadedApk.java:2077)
9com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)
10
11Fatal Exception: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service MyAppPackageHidden/.service.RecorderService
12 at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
13 at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
14 at android.os.Parcel.readParcelable(Parcel.java:3333)
15 at android.os.Parcel.createExceptionOrNull(Parcel.java:2420)
16 at android.os.Parcel.createException(Parcel.java:2409)
17 at android.os.Parcel.readException(Parcel.java:2392)
18 at android.os.Parcel.readException(Parcel.java:2334)
19 at android.app.IActivityManager$Stub$Proxy.startService(IActivityManager.java:5971)
20 at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1847)
21 at android.app.ContextImpl.startForegroundService(ContextImpl.java:1823)
22 at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:779)
23 at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(ContextCompat.java)
24 at androidx.core.content.ContextCompat.startForegroundService(ContextCompat.java:6)
25 at MyAppPackageHidden.service.RecorderService$Companion.startService(RecorderService.java:2)
26 at MyAppPackageHidden.ui.rec.RecActivity$getConnectionRecorderService$1.onServiceConnected(RecActivity.java:4)
27 at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:2077)
28 at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:2110)
29 at android.os.Handler.handleCallback(Handler.java:938)
30 at android.os.Handler.dispatchMessage(Handler.java:99)
31 at android.os.Looper.loopOnce(Looper.java:201)
32 at android.os.Looper.loop(Looper.java:288)
33 at android.app.ActivityThread.main(ActivityThread.java:7838)
34 at java.lang.reflect.Method.invoke(Method.java)
35 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
36 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
37
38Caused by android.os.RemoteException: Remote stack trace:
39 at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:691)
40 at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:616)
41 at com.android.server.am.ActivityManagerService.startService(ActivityManagerService.java:11839)
42 at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2519)
43 at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2498)
44
ANSWER
Answered 2022-Jan-11 at 12:43Apps that target Android 12 (API level 31) or higher can't start foreground services while running in the background, except for a few special cases. If an app tries to start a foreground service while the app is running in the background, and the foreground service doesn't satisfy one of the exceptional cases, the system throws a ForegroundServiceStartNotAllowedException.
Exemptions from background start restrictions
In the following situations, your app can start foreground services even while your app is running in the background:
- Your app transitions from a user-visible state, such as an activity.
- Your app can start an activity from the background, except for the case where the app has an activity in the back stack of an existing task.
- Your app receives a high-priority message using Firebase Cloud Messaging.
- The user performs an action on a UI element related to your app. For example, they might interact with a bubble, notification, widget, or activity.
- Your app invokes an exact alarm to complete an action that the user requests.
- Your app is the device's current input method.
- Your app receives an event that's related to geofencing or activity recognition transition.
- After the device reboots and receives the ACTION_BOOT_COMPLETED, ACTION_LOCKED_BOOT_COMPLETED, or ACTION_MY_PACKAGE_REPLACED intent action in a broadcast receiver.
QUESTION
Getting android.app.ForegroundServiceStartNotAllowedException in Android 12 (SDK 31)
Asked 2021-Dec-17 at 11:23I upgraded my apps targetSdkVersion
and compileSdkVersion
to SDK 31, and started receiving the following crash in app in a service that updates widget in background.
1java.lang.RuntimeException:
2 at android.app.ActivityThread.handleReceiver (ActivityThread.java:4321)
3 at android.app.ActivityThread.access$1600 (ActivityThread.java:247)
4 at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2068)
5 at android.os.Handler.dispatchMessage (Handler.java:106)
6 at android.os.Looper.loopOnce (Looper.java:201)
7 at android.os.Looper.loop (Looper.java:288)
8 at android.app.ActivityThread.main (ActivityThread.java:7842)
9 at java.lang.reflect.Method.invoke (Native Method)
10 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
11 at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)
12Caused by: android.app.ForegroundServiceStartNotAllowedException:
13 at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:54)
14 at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:50)
15 at android.os.Parcel.readParcelable (Parcel.java:3333)
16 at android.os.Parcel.createExceptionOrNull (Parcel.java:2420)
17 at android.os.Parcel.createException (Parcel.java:2409)
18 at android.os.Parcel.readException (Parcel.java:2392)
19 at android.os.Parcel.readException (Parcel.java:2334)
20 at android.app.IActivityManager$Stub$Proxy.startService (IActivityManager.java:5971)
21 at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1847)
22 at android.app.ContextImpl.startForegroundService (ContextImpl.java:1823)
23 at android.content.ContextWrapper.startForegroundService (ContextWrapper.java:779)
24 at android.content.ContextWrapper.startForegroundService (ContextWrapper.java:779)
25 at com.mypackage.appname.ui.widget.widget_package.WidgetClassName.onUpdate (WidgetClassName.java:48)
26 at android.appwidget.AppWidgetProvider.onReceive (AppWidgetProvider.java:66)
27 at com.mypackage.appname.ui.widget.widget_package.WidgetClassName.onReceive (WidgetClassName.java)
28 at android.app.ActivityThread.handleReceiver (ActivityThread.java:4312)
29 at android.app.ActivityThread.access$1600 (ActivityThread.java:247)
30 at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2068)
31 at android.os.Handler.dispatchMessage (Handler.java:106)
32 at android.os.Looper.loopOnce (Looper.java:201)
33 at android.os.Looper.loop (Looper.java:288)
34 at android.app.ActivityThread.main (ActivityThread.java:7842)
35 at java.lang.reflect.Method.invoke (Native Method)
36 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
37 at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)
38Caused by: android.os.RemoteException:
39 at com.android.server.am.ActiveServices.startServiceLocked (ActiveServices.java:691)
40 at com.android.server.am.ActiveServices.startServiceLocked (ActiveServices.java:616)
41 at com.android.server.am.ActivityManagerService.startService (ActivityManagerService.java:11839)
42 at android.app.IActivityManager$Stub.onTransact (IActivityManager.java:2519)
43 at com.android.server.am.ActivityManagerService.onTransact (ActivityManagerService.java:2498)
44
Also, if you're using something like Firebase Crashlytics, your stacktrace must be something like this ->
1java.lang.RuntimeException:
2 at android.app.ActivityThread.handleReceiver (ActivityThread.java:4321)
3 at android.app.ActivityThread.access$1600 (ActivityThread.java:247)
4 at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2068)
5 at android.os.Handler.dispatchMessage (Handler.java:106)
6 at android.os.Looper.loopOnce (Looper.java:201)
7 at android.os.Looper.loop (Looper.java:288)
8 at android.app.ActivityThread.main (ActivityThread.java:7842)
9 at java.lang.reflect.Method.invoke (Native Method)
10 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
11 at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)
12Caused by: android.app.ForegroundServiceStartNotAllowedException:
13 at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:54)
14 at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:50)
15 at android.os.Parcel.readParcelable (Parcel.java:3333)
16 at android.os.Parcel.createExceptionOrNull (Parcel.java:2420)
17 at android.os.Parcel.createException (Parcel.java:2409)
18 at android.os.Parcel.readException (Parcel.java:2392)
19 at android.os.Parcel.readException (Parcel.java:2334)
20 at android.app.IActivityManager$Stub$Proxy.startService (IActivityManager.java:5971)
21 at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1847)
22 at android.app.ContextImpl.startForegroundService (ContextImpl.java:1823)
23 at android.content.ContextWrapper.startForegroundService (ContextWrapper.java:779)
24 at android.content.ContextWrapper.startForegroundService (ContextWrapper.java:779)
25 at com.mypackage.appname.ui.widget.widget_package.WidgetClassName.onUpdate (WidgetClassName.java:48)
26 at android.appwidget.AppWidgetProvider.onReceive (AppWidgetProvider.java:66)
27 at com.mypackage.appname.ui.widget.widget_package.WidgetClassName.onReceive (WidgetClassName.java)
28 at android.app.ActivityThread.handleReceiver (ActivityThread.java:4312)
29 at android.app.ActivityThread.access$1600 (ActivityThread.java:247)
30 at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2068)
31 at android.os.Handler.dispatchMessage (Handler.java:106)
32 at android.os.Looper.loopOnce (Looper.java:201)
33 at android.os.Looper.loop (Looper.java:288)
34 at android.app.ActivityThread.main (ActivityThread.java:7842)
35 at java.lang.reflect.Method.invoke (Native Method)
36 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
37 at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)
38Caused by: android.os.RemoteException:
39 at com.android.server.am.ActiveServices.startServiceLocked (ActiveServices.java:691)
40 at com.android.server.am.ActiveServices.startServiceLocked (ActiveServices.java:616)
41 at com.android.server.am.ActivityManagerService.startService (ActivityManagerService.java:11839)
42 at android.app.IActivityManager$Stub.onTransact (IActivityManager.java:2519)
43 at com.android.server.am.ActivityManagerService.onTransact (ActivityManagerService.java:2498)
44Caused by android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.mypackage.appname/.ui.widget.widget_package.MyForegroundServiceName
45 at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
46 at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
47 at android.os.Parcel.readParcelable(Parcel.java:3333)
48 at android.os.Parcel.createExceptionOrNull(Parcel.java:2420)
49 at android.os.Parcel.createException(Parcel.java:2409)
50 at android.os.Parcel.readException(Parcel.java:2392)
51 at android.os.Parcel.readException(Parcel.java:2334)
52 at android.app.IActivityManager$Stub$Proxy.startService(IActivityManager.java:5971)
53 at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1847)
54 at android.app.ContextImpl.startForegroundService(ContextImpl.java:1823)
55 at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:779)
56 at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:779)
57 at com.mypackage.appname.ui.widget.widget_package.WidgetClassName.onUpdate(WidgetClassName.java:48)
58 at android.appwidget.AppWidgetProvider.onReceive(AppWidgetProvider.java:66)
59 at com.mypackage.appname.ui.widget.widget_package.WidgetClassName.onReceive(WidgetClassName.java)
60 at android.app.ActivityThread.handleReceiver(ActivityThread.java:4312)
61 at android.app.ActivityThread.access$1600(ActivityThread.java:247)
62 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2068)
63 at android.os.Handler.dispatchMessage(Handler.java:106)
64 at android.os.Looper.loopOnce(Looper.java:201)
65 at android.os.Looper.loop(Looper.java:288)
66 at android.app.ActivityThread.main(ActivityThread.java:7842)
67 at java.lang.reflect.Method.invoke(Method.java)
68 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
69 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
70
I'm adding the way to reproduce this issue, and fixes to this problem, because I did not find any documentation about this on StackOverflow when I searched for it.
ANSWER
Answered 2021-Oct-17 at 13:49Step 1. Update your targetSdkVersion
and compileSdkVersion
to SDK 31.
Step 2. Try to run any Foreground service when your app is in background. In my case, it was the widget's onUpdate
method being called after updatePeriodMillis
time, which will start a Foreground service, which updates the data by fetching appropriate information from internet.
Remember: The background execution limits added in Android 8.0 have nothing to do with this problem. This limitation/exception was added in Android 12/SDK 31 - Source.
What is this exception, and why was it added?
Apps that target Android 12 (API level 31) or higher can't start foreground services while running in the background, except for a few special cases. If an app tries to start a foreground service while the app is running in the background, and the foreground service doesn't satisfy one of the exceptional cases, the system throws a ForegroundServiceStartNotAllowedException
.
These special cases are:
Your app transitions from a user-visible state, such as an activity.
Your app can start an activity from the background, except for the case where the app has an activity in the back stack of an existing task.
Your app receives a high-priority message using Firebase Cloud Messaging.
The user performs an action on a UI element related to your app. For example, they might interact with a bubble, notification, widget, or activity.
Your app invokes an exact alarm to complete an action that the user requests.
Your app is the device's current input method.
Your app receives an event that's related to geofencing or activity recognition transition.
After the device reboots and receives the ACTION_BOOT_COMPLETED, ACTION_LOCKED_BOOT_COMPLETED, or ACTION_MY_PACKAGE_REPLACED intent action in a broadcast receiver.
Your app receives the ACTION_TIMEZONE_CHANGED, ACTION_TIME_CHANGED, or ACTION_LOCALE_CHANGED intent action in a broadcast receiver.
Your app receives a Bluetooth broadcast that requires the BLUETOOTH_CONNECT or BLUETOOTH_SCAN permissions.
Apps with certain system roles or permission, such as device owners and profile owners.
Your app uses the Companion Device Manager and declares the REQUEST_COMPANION_START_FOREGROUND_SERVICES_FROM_BACKGROUND permission or the REQUEST_COMPANION_RUN_IN_BACKGROUND permission. Whenever possible, use REQUEST_COMPANION_START_FOREGROUND_SERVICES_FROM_BACKGROUND.
The user turns off battery optimizations for your app. You can help users find this option by sending them to your app's App info page in system settings. To do so, invoke an intent that contains the ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS intent action.
Possible solutions Solution 1
This will work for a while in Play Store until Google makes it mandatory to upgrade to API level 31.
Currently, starting November 2021 all apps must target API Level 30 and above. So if you're using API Level 31 for your app, downgrading your compileSdkVersion
& targetSdkVersion
to API Level 30 should fix the issue (atleast for a while).
If you were using Foreground service to do work that is time sensitive, start Foreground services within an exact alarm. Check out more about this from documentation here -> Set an exact alarm.
For time-insensitive/expedited workThis is the solution that I ended up using for my app. Use WorkManager
to schedule and start the background work. Check out more about this from documentation here -> Schedule expedited work.
You can know more about WorkManager here -> WorkManager
Github Repo for WorkManager samples -> WorkManager Samples
I added this answer specifically because searching for this exception does not bring up any resources to know why the service behaves differently on Android 12. All this is present in Google's documentation, and always remember to check the behaviour changes from the doc.
Everything related to this change can be found here -> Android 12 Behavior Changes, specifically within the Foreground Service launch restrictions.
QUESTION
"Theming Icons" functionality crashes live wallpapers on Android 12
Asked 2021-Dec-07 at 22:23I recently noticed that my live wallpaper apps are crashing when users try to set the newly introduced "Theming Icons" functionality on Android 12. This new functionality calculates a palette of colors from the user's current static wallpaper and uses this palette to color some of the other apps icons (a feature of the new "Material You" design). But for some reason when it operates on a live wallpaper it crashes the app with the following log:
1Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Bitmap android.graphics.drawable.BitmapDrawable.getBitmap()' on a null object reference
2 at android.os.Parcel.createExceptionOrNull(Parcel.java:2443)
3 at android.os.Parcel.createException(Parcel.java:2421)
4 at android.os.Parcel.readException(Parcel.java:2404)
5 at android.os.Parcel.readException(Parcel.java:2346)
6 at android.service.wallpaper.IWallpaperConnection$Stub$Proxy.onWallpaperColorsChanged(IWallpaperConnection.java:298)
7 at android.service.wallpaper.WallpaperService$IWallpaperEngineWrapper.executeMessage(WallpaperService.java:2586)
8 at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:44)
9 at android.os.Handler.dispatchMessage(Handler.java:106)
10 at android.os.Looper.loopOnce(Looper.java:226)
11 at android.os.Looper.loop(Looper.java:313)
12 at android.app.ActivityThread.main(ActivityThread.java:8582)
13 at java.lang.reflect.Method.invoke(Method.java)
14 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:563)
15 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)
16
17
18Caused by android.os.RemoteException: Remote stack trace:
19 at com.samsung.server.wallpaper.LegibilityColor.convertColors(LegibilityColor.java:418)
20 at com.android.server.wallpaper.WallpaperManagerService$WallpaperConnection.onWallpaperColorsChanged(WallpaperManagerService.java:2169)
21 at android.service.wallpaper.IWallpaperConnection$Stub.onTransact(IWallpaperConnection.java:158)
22 at android.os.Binder.execTransactInternal(Binder.java:1215)
23 at android.os.Binder.execTransact(Binder.java:1179)
24
At this moment I can observe this crash only on Samsung Galaxy S21 / S21 Ultra phones but it will be present on many more phones as users update their system to Android 12.
Currently, I cannot reproduce this crash because I don't own a Galaxy S21 and the Android Studio emulator still misses the "Theming Icons" option (maybe because this functionality is currently still in beta).
Does anybody have any clue on how to solve this catastrophic problem? Any help is greatly appreciated!
Update November 18: I was able to test the new "Themed icon" feature on the Android Studio Emulator (on the newly introduced "SV2" release). This release is really buggy but I was not able to reproduce a similar crash. It makes me think that this crash is exclusive to Samsung phones.
I tried to test some Galaxy S21 devices from the publicly available phones at the "Galaxy Mobile - Remote Test Lab" site, but they implement a beta version of Android 12 where the Themed Icon feature is not available.
I want to generate a complete crash report (log + video) to send to Samsung but I still can't find a Galaxy S21 with Android 12 installed (the Android 12 system update started on November 15 for Galaxy S21 phones). In the meantime, the crash reports are exploding as many more users are updating their phones to Android 12...Such a shame!
ANSWER
Answered 2021-Nov-30 at 22:05For a while I was looking for a similar problem in reviews of popular live wallpapers. I found similar reviews only for one application. I updated my phone today. All my live wallpapers stopped working as expected. Then I installed "Earth & Moon" and this app works fine. It means that we are doing something wrong or, on the contrary, we are not doing something :) In the near future I will begin to investigate this problem.
Community Discussions contain sources that include Stack Exchange Network