问:
Configure @Autowired from application.yml
We have some beans that are conditional

```<code>@Service
@ConditionalOnProperties("${condition}")
class Foo {
 ...
}
</code>```

We want to be able to autowire those bean based on the same condition, is there a way to do something like:

```<code>@Autowired(required="${condition}")
private Foo foo;
</code>```

Is there a way to obtains such result using properties from application.yml ?

答:
You can try using SPEL.
For example: @Autowired(required="#{ systemProperties['user.region'] }")

Body:
We have some beans that are conditional

@Service
@ConditionalOnProperties("${condition}")
class Foo {
 ...
}

We want to be able to autowire those bean based on the same condition, is there a way to do something like:

@Autowired(required="${condition}")
private Foo foo;

Is there a way to obtains such result using properties from application.yml ?


来源: stackexchange

问:
How to make record insert operation faster in django with postgres backend
I build a django based geolocation service which determines user's location by their IP address. The first thing I need to do is to insert ip data into my database.

I used following code(simplified) to insert records into my db:

```<code> for ipLoc in ipSeeker.ipLocationList:
     placeName =ipLoc.country + ipLoc.area
     IPLog.objects.create(
                startIP = int_to_dqn(ipLoc.startIP),
                endIP = int_to_dqn(ipLoc.endIP),
                place = placeName
     ).save()
</code>```

The ipLocationList has approx 400k ip records. And my script only insert 20k records in 20 minutes. It is tooooooo slow and could not be accepted.

So my question is: where is the bottleneck and how could I make it faster?

Thanks in advance!

答:
Use raw sql and transactions for django-side: https://docs.djangoproject.com/en/dev/topics/db/sql/ along with the Copy command from Postgres!

Whats the fastest way to do a bulk insert into Postgres?

ContentLicense: CC BY-SA 3.0

Body:
I build a django based geolocation service which determines user's location by their IP address. The first thing I need to do is to insert ip data into my database.

I used following code(simplified) to insert records into my db:

 for ipLoc in ipSeeker.ipLocationList:
     placeName =ipLoc.country + ipLoc.area
     IPLog.objects.create(
                startIP = int_to_dqn(ipLoc.startIP),
                endIP = int_to_dqn(ipLoc.endIP),
                place = placeName
     ).save()

The ipLocationList has approx 400k ip records. And my script only insert 20k records in 20 minutes. It is tooooooo slow and could not be accepted.

So my question is: where is the bottleneck and how could I make it faster?

Thanks in advance!


问:
Embedding Power BI dashboard in an email
I have developed a dashboard in Power BI that I would like to embed in an email body - Outlook, Gmail etc. Is this possible please and has anyone been successful at doing this?</p>

答: No, embedding requires a lot of javascript code and a modern browser to work. Currently it is not possible to get this working in an e-mail body, because it will violate event basic security policies. Embed it in a web application hosted somewhere (or if the recipients has access to it, you can leave it in Power BI Service) and send and link to it (you can add an image if you want) in the e-mail.</p>

ContentLicense: CC BY-SA 4.0


问:
Resampling many timeseries files with pandas/dask
I have many .csv files with two columns. One with timestamps and the other with values. The data is sampled on seconds. What I would like to do is

read all files

set index on time column

resample on hours

save to new files (parquet, hdf,...)

1) Only dask

I tried to use dask's read_csv.

import dask.dataframe as dd
import pandas as pd

df = dd.read_csv(
    "../data_*.csv",
    parse_dates = [0],
    date_parser = lambda x: pd.to_datetime(float(x)),
)
```
<p>So far that's fine. The problem is that I cannot <code>df.resample("min").mean()</code> directly, because the index of dask data frame is not properly set.</p>
<p>After calling <code>dd.reset_index().set_index("timestamp")</code> it works - <strong>BUT</strong>  I cannot afford to do this because it is expensive.</p>
<p><strong>2) Workaround with <code>pandas</code> and <code>hdf</code> files</strong></p>
<p>Another approach was to save all <code>csv</code> files to <code>hdf</code> files using pandas. In this case the pandas dataframes were already indexed by time.</p>
```df= dd.read_hdf("/data_01.hdf", key="data")

# This doesn't work directly
# df = df.resample("min").mean()
# Error: "Can only resample dataframes with known divisions"

df = df.reset_index().set_index("timestamp")  # expensive! :-(
df = df.resample("min").mean()  # works!
```
<p>Of course this works but it would be extremely expensive on <code>dd.read_hdf("/data_*.hdf", key="data")</code>.</p>
<p>How can I directly read timeseries data in dask that it is properly partitioned and indexed?
Do you have any tips or suggestions?</p>
<hr />
<p>Exmpample Data:</p>
```import dask

df = dask.datasets.timeseries()
df.to_hdf("dask.hdf", "data")

# Doesn't work!
# dd.read_hdf("dask.hdf", key="data").resample("min").mean()

# Works!
dd.read_hdf("dask.hdf", key="data").reset_index().set_index("timestamp").resample(
    "min"
).mean()
```

答:
Can you try something like:</p>
```<code>pd.read_csv('data.csv', index_col='timestamp', parse_dates=['timestamp']) \
  .resample('T').mean().to_csv('data_1min.csv')  # or to_hdf(...)
</code>```

Body:
I have many .csv files with two columns. One with timestamps and the other with values. The data is sampled on seconds. What I would like to do is

read all files

set index on time column

resample on hours

save to new files (parquet, hdf,...)

1) Only dask

I tried to use dask's read_csv.

import dask.dataframe as dd
import pandas as pd

df = dd.read_csv(
    "../data_*.csv",
    parse_dates = [0],
    date_parser = lambda x: pd.to_datetime(float(x)),
)

So far that's fine. The problem is that I cannot df.resample("min").mean() directly, because the index of dask data frame is not properly set.

After calling dd.reset_index().set_index("timestamp") it works - BUT  I cannot afford to do this because it is expensive.

2) Workaround with pandas and hdf files

Another approach was to save all csv files to hdf files using pandas. In this case the pandas dataframes were already indexed by time.

df= dd.read_hdf("/data_01.hdf", key="data")

# This doesn't work directly
# df = df.resample("min").mean()
# Error: "Can only resample dataframes with known divisions"

df = df.reset_index().set_index("timestamp")  # expensive! :-(
df = df.resample("min").mean()  # works!

Of course this works but it would be extremely expensive on dd.read_hdf("/data_*.hdf", key="data").

How can I directly read timeseries data in dask that it is properly partitioned and indexed?
Do you have any tips or suggestions?

Exmpample Data:

import dask

df = dask.datasets.timeseries()
df.to_hdf("dask.hdf", "data")

# Doesn't work!
# dd.read_hdf("dask.hdf", key="data").resample("min").mean()

# Works!
dd.read_hdf("dask.hdf", key="data").reset_index().set_index("timestamp").resample(
    "min"
).mean()

Body:
Can you try something like:

pd.read_csv('data.csv', index_col='timestamp', parse_dates=['timestamp']) \
  .resample('T').mean().to_csv('data_1min.csv')  # or to_hdf(...)


问:
How to make HttpClient stops processing
I have a strange issue and I can't find the solution.
I have the following code for building my ClosableHttpClient :

private void createClient() {
  int timeout = 5;
  RequestConfig config = RequestConfig.custom()
    .setConnectTimeout(timeout * 1000)
    .setConnectionRequestTimeout(timeout * 1000)
    .setSocketTimeout(timeout * 1000).build();

  final SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
    final HostnameVerifier defaultHostnameVerifier = SSLConnectionSocketFactory.getDefaultHostnameVerifier();
    final SSLConnectionSocketFactory systemSocketFactory = new SSLConnectionSocketFactory(socketFactory, defaultHostnameVerifier);
    httpclient = HttpClients.custom()
        .setSSLSocketFactory(systemSocketFactory)
        .setDefaultRequestConfig(config)
        .build();
}
```
<p>and than I'm trying this:</p>
<pre class="lang-java prettyprint-override"><code>private JSONObject sendPostRequest(String url, StringEntity postData) throws HttpException, IOException {
  HttpPost request = new HttpPost(url);
  for (String key : headers.keySet()) {
    request.addHeader(key, headers.get(key));
  }
  request.setEntity(postData);

  HttpResponse response = httpclient.execute(request);

  int statusCode = response.getStatusLine().getStatusCode();

  if (statusCode == HttpStatus.SC_OK) {
    String content = EntityUtils.toString(response.getEntity());
    return new JSONObject(content);
  } else if (statusCode == HttpStatus.SC_UNAUTHORIZED) {
    throw new HttpException("Autorisierung nicht möglich");
  }
  throw new HttpException(String.valueOf(statusCode));
}
</code>```

the code stops at httpclient.execute(). And I mean it stops. There is nothing after, no log no stacktrace nothing. When I try my code on localhost ther is the following debug-log

```<code>[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.client.protocol.RequestAddCookies:123 - CookieSpec selected: default
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.client.protocol.RequestAuthCache:77 - Auth cache not set in the context
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:267 - Connection request: [route: {s}->https://doesnt.matter:8443][total available: 0; route allocated: 0 of 2; total allocated: 0 of 20]
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:312 - Connection leased: [id: 0][route: {s}->https://doesnt.matter:8443][total available: 0; route allocated: 1 of 2; total allocated: 1 of 20]
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.impl.execchain.MainClientExec:234 - Opening connection {s}->https://doesnt.matter:8443
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.DefaultHttpClientConnectionOperator:139 - Connecting to doesnt.matter/1.2.1.8:8443
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:366 - Connecting socket to doesnt.matter/1.2.1.8:8443 with timeout 5000
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:430 - Enabled protocols: [TLSv1.2]
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:431 - Enabled cipher suites:[SSL_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, SSL_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, SSL_ECDHE_RSA_WITH_AES_256_GCM_SHA384, SSL_RSA_WITH_AES_256_GCM_SHA384, SSL_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, SSL_ECDH_RSA_WITH_AES_256_GCM_SHA384, SSL_DHE_RSA_WITH_AES_256_GCM_SHA384, SSL_DHE_DSS_WITH_AES_256_GCM_SHA384, SSL_ECDHE_RSA_WITH_AES_128_GCM_SHA256, SSL_RSA_WITH_AES_128_GCM_SHA256, SSL_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, SSL_ECDH_RSA_WITH_AES_128_GCM_SHA256, SSL_DHE_RSA_WITH_AES_128_GCM_SHA256, SSL_DHE_DSS_WITH_AES_128_GCM_SHA256, SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, SSL_ECDHE_RSA_WITH_AES_256_CBC_SHA384, SSL_RSA_WITH_AES_256_CBC_SHA256, SSL_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, SSL_ECDH_RSA_WITH_AES_256_CBC_SHA384, SSL_DHE_RSA_WITH_AES_256_CBC_SHA256, SSL_DHE_DSS_WITH_AES_256_CBC_SHA256, SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, SSL_ECDHE_RSA_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_AES_256_CBC_SHA, SSL_ECDH_ECDSA_WITH_AES_256_CBC_SHA, SSL_ECDH_RSA_WITH_AES_256_CBC_SHA, SSL_DHE_RSA_WITH_AES_256_CBC_SHA, SSL_DHE_DSS_WITH_AES_256_CBC_SHA, SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, SSL_ECDHE_RSA_WITH_AES_128_CBC_SHA256, SSL_RSA_WITH_AES_128_CBC_SHA256, SSL_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, SSL_ECDH_RSA_WITH_AES_128_CBC_SHA256, SSL_DHE_RSA_WITH_AES_128_CBC_SHA256, SSL_DHE_DSS_WITH_AES_128_CBC_SHA256, SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, SSL_ECDHE_RSA_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_AES_128_CBC_SHA, SSL_ECDH_ECDSA_WITH_AES_128_CBC_SHA, SSL_ECDH_RSA_WITH_AES_128_CBC_SHA, SSL_DHE_RSA_WITH_AES_128_CBC_SHA, SSL_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:435 - Starting handshake
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:465 - Secure session established
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:466 -  negotiated protocol: TLSv1.2
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:467 -  negotiated cipher suite: SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:475 -  peer principal: CN=doesnt.matter, OU=D100, OU=SSL Server, OU=SSL, O=Finanz Informatik, C=DE
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:484 -  peer alternative names: [doesnt.matter]
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:488 -  issuer principal: CN=Finanz Informatik Issuing CA 01, OU=PKI, O=Finanz Informatik, C=DE
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.DefaultHttpClientConnectionOperator:146 - Connection established 16.160.132.187:58678<->17.239.174.83:8443
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.DefaultManagedHttpClientConnection:88 - http-outgoing-0: set socket timeout to 5000
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.execchain.MainClientExec:255 - Executing request POST /rest-api/authenticate HTTP/1.1
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.execchain.MainClientExec:260 - Target auth state: UNCHALLENGED
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.execchain.MainClientExec:266 - Proxy auth state: UNCHALLENGED
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:133 - http-outgoing-0 >> POST /rest-api/authenticate HTTP/1.1
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> Content-Length: 88
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> Content-Type: application/json; charset=UTF-8
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> Host: doesnt.matter:8443
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> Connection: Keep-Alive
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_291)
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> Accept-Encoding: gzip,deflate
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "POST /rest-api/authenticate HTTP/1.1[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "Content-Length: 88[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "Content-Type: application/json; charset=UTF-8[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "Host: doesnt.matter:8443[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_291)[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:87 - http-outgoing-0 >> "{"clientContext":1,"password":"*********","repository":"UCMDB","username":"******"}"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Date: Fri, 11 Feb 2022 08:29:10 GMT[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "X-FRAME-OPTIONS: [\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Content-Security-Policy: frame-ancestors 'self'[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "X-Content-Type-Options: nosniff[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "X-Xss-Protection: 1; mode=block[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Strict-Transport-Security: max-age=31536000;includeSubDomains[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Cache-Control: no-store[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "IE-Language: en[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Access-Control-Allow-Origin: *[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Access-Control-Allow-Credentials: true[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Access-Control-Allow-Methods: POST, PUT, GET, HEAD, OPTIONS, PATCH, DELETE[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Access-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers , Authorization, Cache-Control, Pragma, Expires[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Access-Control-Max-Age: 17200[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Set-Cookie: JSESSIONID=node01dumaqs3jy4ycc2vtykxc0btx188; HttpOnly; secure; path=/rest-api[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Content-Type: application/json[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Content-Length: 243[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "{[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "  "token" : "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1bmlxdWVfc2FsdCI6IlY5OTBTVFdNVlFPUkEwMSIsImV4cCI6MTY0NDU3MTc1MCwicmVwb3NpdG9yeSI6IlVDTURCIiwiY3VzdG9tZXIiOjEsInVzZXJuYW1lIjoic3lzYWRtaW4ifQ.-BzMAsqUT0FdEpMsf0M__FodAP3yv7JOelXMvzwQBK4"[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:87 - http-outgoing-0 << "}"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:122 - http-outgoing-0 << HTTP/1.1 200 OK
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Date: Fri, 11 Feb 2022 08:29:10 GMT
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << X-FRAME-OPTIONS:
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Content-Security-Policy: frame-ancestors 'self'
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << X-Content-Type-Options: nosniff
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << X-Xss-Protection: 1; mode=block
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Strict-Transport-Security: max-age=31536000;includeSubDomains
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Cache-Control: no-store
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << IE-Language: en
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Access-Control-Allow-Origin: *
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Access-Control-Allow-Credentials: true
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Access-Control-Allow-Methods: POST, PUT, GET, HEAD, OPTIONS, PATCH, DELETE
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Access-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers , Authorization, Cache-Control, Pragma, Expires
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Access-Control-Max-Age: 17200
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Set-Cookie: JSESSIONID=node01dumaqs3jy4ycc2vtykxc0btx188; HttpOnly; secure; path=/rest-api
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Expires: Thu, 01 Jan 1970 00:00:00 GMT
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Content-Type: application/json
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Content-Length: 243
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.execchain.MainClientExec:285 - Connection can be kept alive indefinitely
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.client.protocol.ResponseProcessCookies:119 - Cookie accepted [JSESSIONID="node01dumaqs3jy4ycc2vtykxc0btx188", version:0, domain:doesnt.matter, path:/rest-api, expiry:null]
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:344 - Connection [id: 0][route: {s}->https://doesnt.matter:8443] can be kept alive indefinitely
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.DefaultManagedHttpClientConnection:88 - http-outgoing-0: set socket timeout to 0
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:351 - Connection released: [id: 0][route: {s}->https://doesnt.matter:8443][total available: 1; route allocated: 1 of 2; total allocated: 1 of 20]
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:411 - Connection manager is shutting down
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.DefaultManagedHttpClientConnection:79 - http-outgoing-0: Close connection
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:434 - Connection manager shut down
</code>```

When I deploy it to the WLP Server I only get the following output

```<code>[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.client.protocol.RequestAddCookies:123 - CookieSpec selected: default
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.client.protocol.RequestAuthCache:77 - Auth cache not set in the context
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.PoolingHttpClientConnectionManager:267 - Connection request: [route: {s}->https://doesnt.matter:8443][total available: 0; route allocated: 0 of 2; total allocated: 0 of 20]
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.PoolingHttpClientConnectionManager:312 - Connection leased: [id: 120][route: {s}->https://doesnt.matter:8443][total available: 0; route allocated: 1 of 2; total allocated: 1 of 20]
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.impl.execchain.MainClientExec:234 - Opening connection {s}->https://doesnt.matter:8443
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.DefaultHttpClientConnectionOperator:139 - Connecting to doesnt.matter/1.2.1.8:8443
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.conn.ssl.SSLConnectionSocketFactory:366 - Connecting socket to doesnt.matter/1.2.1.8:8443 with timeout 5000
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.conn.ssl.SSLConnectionSocketFactory:430 - Enabled protocols: [TLSv1.2]
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.conn.ssl.SSLConnectionSocketFactory:431 - Enabled cipher suites:[SSL_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, SSL_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, SSL_ECDHE_RSA_WITH_AES_256_GCM_SHA384, SSL_DHE_RSA_WITH_AES_256_GCM_SHA384, SSL_DHE_DSS_WITH_AES_256_GCM_SHA384, SSL_ECDHE_RSA_WITH_AES_128_GCM_SHA256, SSL_DHE_RSA_WITH_AES_128_GCM_SHA256, SSL_DHE_DSS_WITH_AES_128_GCM_SHA256]
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.conn.ssl.SSLConnectionSocketFactory:435 - Starting handshake
[2022-02-11T09:25:50] [DEBUG] [Finalizer thread] apache.http.impl.conn.PoolingHttpClientConnectionManager:411 - Connection manager is shutting down
[2022-02-11T09:25:50] [DEBUG] [Finalizer thread] apache.http.impl.conn.PoolingHttpClientConnectionManager:434 - Connection manager shut down
[2022-02-11T09:26:23] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.PoolingHttpClientConnectionManager:411 - Connection manager is shutting down
[2022-02-11T09:26:23] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.DefaultManagedHttpClientConnection:96 - http-outgoing-120: Shutdown connection
[2022-02-11T09:26:23] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.PoolingHttpClientConnectionManager:434 - Connection manager shut down
</code>```

And as I said than there is nothing. My code stops proceeding. This test is made every 15 Minutes and it is in a for-next-loop with some other tests. If it wold send an exception the for-next could work on, but it only stops working. Can someone tell my why it only stops and doesn't send something back to the application and help me making it stop so the other tasks are run.

答:
The only difference I see between your LocalHost vs your Client connection is the following:

```<code>[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:435 - Starting handshake
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:465 - Secure session established
</code>```

While for your client:

```<code>[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.conn.ssl.SSLConnectionSocketFactory:435 - Starting handshake
[2022-02-11T09:25:50] [DEBUG] [Finalizer thread] apache.http.impl.conn.PoolingHttpClientConnectionManager:411 - Connection manager is shutting down
</code>```

You could be facing 2 issues:

You are on a server which has network firewall of some kind, which does not allow you to access the specific IP you are attempting to reach, therefore the connection is getting killed instantly.

Another issue might be that your SSL connection for that IP is invalid, however I think this is less likely, because if there is a problem in SSL, you could get some debug info regarding that.

Title: How to make HttpClient stops processing

Body:
I have a strange issue and I can't find the solution.
I have the following code for building my ClosableHttpClient :

private void createClient() {
  int timeout = 5;
  RequestConfig config = RequestConfig.custom()
    .setConnectTimeout(timeout * 1000)
    .setConnectionRequestTimeout(timeout * 1000)
    .setSocketTimeout(timeout * 1000).build();

  final SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
    final HostnameVerifier defaultHostnameVerifier = SSLConnectionSocketFactory.getDefaultHostnameVerifier();
    final SSLConnectionSocketFactory systemSocketFactory = new SSLConnectionSocketFactory(socketFactory, defaultHostnameVerifier);
    httpclient = HttpClients.custom()
        .setSSLSocketFactory(systemSocketFactory)
        .setDefaultRequestConfig(config)
        .build();
}

and than I'm trying this:

private JSONObject sendPostRequest(String url, StringEntity postData) throws HttpException, IOException {
  HttpPost request = new HttpPost(url);
  for (String key : headers.keySet()) {
    request.addHeader(key, headers.get(key));
  }
  request.setEntity(postData);

  HttpResponse response = httpclient.execute(request);

  int statusCode = response.getStatusLine().getStatusCode();

  if (statusCode == HttpStatus.SC_OK) {
    String content = EntityUtils.toString(response.getEntity());
    return new JSONObject(content);
  } else if (statusCode == HttpStatus.SC_UNAUTHORIZED) {
    throw new HttpException("Autorisierung nicht möglich");
  }
  throw new HttpException(String.valueOf(statusCode));
}

the code stops at httpclient.execute(). And I mean it stops. There is nothing after, no log no stacktrace nothing. When I try my code on localhost ther is the following debug-log

[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.client.protocol.RequestAddCookies:123 - CookieSpec selected: default
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.client.protocol.RequestAuthCache:77 - Auth cache not set in the context
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:267 - Connection request: [route: {s}->https://doesnt.matter:8443][total available: 0; route allocated: 0 of 2; total allocated: 0 of 20]
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:312 - Connection leased: [id: 0][route: {s}->https://doesnt.matter:8443][total available: 0; route allocated: 1 of 2; total allocated: 1 of 20]
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.impl.execchain.MainClientExec:234 - Opening connection {s}->https://doesnt.matter:8443
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.DefaultHttpClientConnectionOperator:139 - Connecting to doesnt.matter/1.2.1.8:8443
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:366 - Connecting socket to doesnt.matter/1.2.1.8:8443 with timeout 5000
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:430 - Enabled protocols: [TLSv1.2]
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:431 - Enabled cipher suites:[SSL_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, SSL_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, SSL_ECDHE_RSA_WITH_AES_256_GCM_SHA384, SSL_RSA_WITH_AES_256_GCM_SHA384, SSL_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, SSL_ECDH_RSA_WITH_AES_256_GCM_SHA384, SSL_DHE_RSA_WITH_AES_256_GCM_SHA384, SSL_DHE_DSS_WITH_AES_256_GCM_SHA384, SSL_ECDHE_RSA_WITH_AES_128_GCM_SHA256, SSL_RSA_WITH_AES_128_GCM_SHA256, SSL_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, SSL_ECDH_RSA_WITH_AES_128_GCM_SHA256, SSL_DHE_RSA_WITH_AES_128_GCM_SHA256, SSL_DHE_DSS_WITH_AES_128_GCM_SHA256, SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, SSL_ECDHE_RSA_WITH_AES_256_CBC_SHA384, SSL_RSA_WITH_AES_256_CBC_SHA256, SSL_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, SSL_ECDH_RSA_WITH_AES_256_CBC_SHA384, SSL_DHE_RSA_WITH_AES_256_CBC_SHA256, SSL_DHE_DSS_WITH_AES_256_CBC_SHA256, SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, SSL_ECDHE_RSA_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_AES_256_CBC_SHA, SSL_ECDH_ECDSA_WITH_AES_256_CBC_SHA, SSL_ECDH_RSA_WITH_AES_256_CBC_SHA, SSL_DHE_RSA_WITH_AES_256_CBC_SHA, SSL_DHE_DSS_WITH_AES_256_CBC_SHA, SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, SSL_ECDHE_RSA_WITH_AES_128_CBC_SHA256, SSL_RSA_WITH_AES_128_CBC_SHA256, SSL_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, SSL_ECDH_RSA_WITH_AES_128_CBC_SHA256, SSL_DHE_RSA_WITH_AES_128_CBC_SHA256, SSL_DHE_DSS_WITH_AES_128_CBC_SHA256, SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, SSL_ECDHE_RSA_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_AES_128_CBC_SHA, SSL_ECDH_ECDSA_WITH_AES_128_CBC_SHA, SSL_ECDH_RSA_WITH_AES_128_CBC_SHA, SSL_DHE_RSA_WITH_AES_128_CBC_SHA, SSL_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:435 - Starting handshake
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:465 - Secure session established
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:466 -  negotiated protocol: TLSv1.2
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:467 -  negotiated cipher suite: SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:475 -  peer principal: CN=doesnt.matter, OU=D100, OU=SSL Server, OU=SSL, O=Finanz Informatik, C=DE
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:484 -  peer alternative names: [doesnt.matter]
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:488 -  issuer principal: CN=Finanz Informatik Issuing CA 01, OU=PKI, O=Finanz Informatik, C=DE
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.DefaultHttpClientConnectionOperator:146 - Connection established 16.160.132.187:58678<->17.239.174.83:8443
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.DefaultManagedHttpClientConnection:88 - http-outgoing-0: set socket timeout to 5000
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.execchain.MainClientExec:255 - Executing request POST /rest-api/authenticate HTTP/1.1
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.execchain.MainClientExec:260 - Target auth state: UNCHALLENGED
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.execchain.MainClientExec:266 - Proxy auth state: UNCHALLENGED
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:133 - http-outgoing-0 >> POST /rest-api/authenticate HTTP/1.1
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> Content-Length: 88
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> Content-Type: application/json; charset=UTF-8
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> Host: doesnt.matter:8443
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> Connection: Keep-Alive
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_291)
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:136 - http-outgoing-0 >> Accept-Encoding: gzip,deflate
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "POST /rest-api/authenticate HTTP/1.1[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "Content-Length: 88[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "Content-Type: application/json; charset=UTF-8[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "Host: doesnt.matter:8443[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_291)[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 >> "[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:87 - http-outgoing-0 >> "{"clientContext":1,"password":"*********","repository":"UCMDB","username":"******"}"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Date: Fri, 11 Feb 2022 08:29:10 GMT[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "X-FRAME-OPTIONS: [\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Content-Security-Policy: frame-ancestors 'self'[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "X-Content-Type-Options: nosniff[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "X-Xss-Protection: 1; mode=block[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Strict-Transport-Security: max-age=31536000;includeSubDomains[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Cache-Control: no-store[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "IE-Language: en[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Access-Control-Allow-Origin: *[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Access-Control-Allow-Credentials: true[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Access-Control-Allow-Methods: POST, PUT, GET, HEAD, OPTIONS, PATCH, DELETE[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Access-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers , Authorization, Cache-Control, Pragma, Expires[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Access-Control-Max-Age: 17200[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Set-Cookie: JSESSIONID=node01dumaqs3jy4ycc2vtykxc0btx188; HttpOnly; secure; path=/rest-api[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Content-Type: application/json[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "Content-Length: 243[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "{[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:73 - http-outgoing-0 << "  "token" : "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1bmlxdWVfc2FsdCI6IlY5OTBTVFdNVlFPUkEwMSIsImV4cCI6MTY0NDU3MTc1MCwicmVwb3NpdG9yeSI6IlVDTURCIiwiY3VzdG9tZXIiOjEsInVzZXJuYW1lIjoic3lzYWRtaW4ifQ.-BzMAsqUT0FdEpMsf0M__FodAP3yv7JOelXMvzwQBK4"[\r][\n]"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.wire:87 - http-outgoing-0 << "}"
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:122 - http-outgoing-0 << HTTP/1.1 200 OK
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Date: Fri, 11 Feb 2022 08:29:10 GMT
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << X-FRAME-OPTIONS:
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Content-Security-Policy: frame-ancestors 'self'
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << X-Content-Type-Options: nosniff
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << X-Xss-Protection: 1; mode=block
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Strict-Transport-Security: max-age=31536000;includeSubDomains
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Cache-Control: no-store
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << IE-Language: en
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Access-Control-Allow-Origin: *
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Access-Control-Allow-Credentials: true
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Access-Control-Allow-Methods: POST, PUT, GET, HEAD, OPTIONS, PATCH, DELETE
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Access-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers , Authorization, Cache-Control, Pragma, Expires
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Access-Control-Max-Age: 17200
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Set-Cookie: JSESSIONID=node01dumaqs3jy4ycc2vtykxc0btx188; HttpOnly; secure; path=/rest-api
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Expires: Thu, 01 Jan 1970 00:00:00 GMT
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Content-Type: application/json
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] org.apache.http.headers:125 - http-outgoing-0 << Content-Length: 243
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.execchain.MainClientExec:285 - Connection can be kept alive indefinitely
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.client.protocol.ResponseProcessCookies:119 - Cookie accepted [JSESSIONID="node01dumaqs3jy4ycc2vtykxc0btx188", version:0, domain:doesnt.matter, path:/rest-api, expiry:null]
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:344 - Connection [id: 0][route: {s}->https://doesnt.matter:8443] can be kept alive indefinitely
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.DefaultManagedHttpClientConnection:88 - http-outgoing-0: set socket timeout to 0
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:351 - Connection released: [id: 0][route: {s}->https://doesnt.matter:8443][total available: 1; route allocated: 1 of 2; total allocated: 1 of 20]
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:411 - Connection manager is shutting down
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.DefaultManagedHttpClientConnection:79 - http-outgoing-0: Close connection
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.impl.conn.PoolingHttpClientConnectionManager:434 - Connection manager shut down

When I deploy it to the WLP Server I only get the following output

[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.client.protocol.RequestAddCookies:123 - CookieSpec selected: default
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.client.protocol.RequestAuthCache:77 - Auth cache not set in the context
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.PoolingHttpClientConnectionManager:267 - Connection request: [route: {s}->https://doesnt.matter:8443][total available: 0; route allocated: 0 of 2; total allocated: 0 of 20]
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.PoolingHttpClientConnectionManager:312 - Connection leased: [id: 120][route: {s}->https://doesnt.matter:8443][total available: 0; route allocated: 1 of 2; total allocated: 1 of 20]
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.impl.execchain.MainClientExec:234 - Opening connection {s}->https://doesnt.matter:8443
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.DefaultHttpClientConnectionOperator:139 - Connecting to doesnt.matter/1.2.1.8:8443
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.conn.ssl.SSLConnectionSocketFactory:366 - Connecting socket to doesnt.matter/1.2.1.8:8443 with timeout 5000
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.conn.ssl.SSLConnectionSocketFactory:430 - Enabled protocols: [TLSv1.2]
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.conn.ssl.SSLConnectionSocketFactory:431 - Enabled cipher suites:[SSL_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, SSL_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, SSL_ECDHE_RSA_WITH_AES_256_GCM_SHA384, SSL_DHE_RSA_WITH_AES_256_GCM_SHA384, SSL_DHE_DSS_WITH_AES_256_GCM_SHA384, SSL_ECDHE_RSA_WITH_AES_128_GCM_SHA256, SSL_DHE_RSA_WITH_AES_128_GCM_SHA256, SSL_DHE_DSS_WITH_AES_128_GCM_SHA256]
[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.conn.ssl.SSLConnectionSocketFactory:435 - Starting handshake
[2022-02-11T09:25:50] [DEBUG] [Finalizer thread] apache.http.impl.conn.PoolingHttpClientConnectionManager:411 - Connection manager is shutting down
[2022-02-11T09:25:50] [DEBUG] [Finalizer thread] apache.http.impl.conn.PoolingHttpClientConnectionManager:434 - Connection manager shut down
[2022-02-11T09:26:23] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.PoolingHttpClientConnectionManager:411 - Connection manager is shutting down
[2022-02-11T09:26:23] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.DefaultManagedHttpClientConnection:96 - http-outgoing-120: Shutdown connection
[2022-02-11T09:26:23] [DEBUG] [Default Executor-thread-576] apache.http.impl.conn.PoolingHttpClientConnectionManager:434 - Connection manager shut down

And as I said than there is nothing. My code stops proceeding. This test is made every 15 Minutes and it is in a for-next-loop with some other tests. If it wold send an exception the for-next could work on, but it only stops working. Can someone tell my why it only stops and doesn't send something back to the application and help me making it stop so the other tasks are run.

Body:
The only difference I see between your LocalHost vs your Client connection is the following:

[2022-02-11T09:29:10] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:435 - Starting handshake
[2022-02-11T09:29:11] [DEBUG] [Default Executor-thread-2] apache.http.conn.ssl.SSLConnectionSocketFactory:465 - Secure session established

While for your client:

[2022-02-11T09:25:50] [DEBUG] [Default Executor-thread-576] apache.http.conn.ssl.SSLConnectionSocketFactory:435 - Starting handshake
[2022-02-11T09:25:50] [DEBUG] [Finalizer thread] apache.http.impl.conn.PoolingHttpClientConnectionManager:411 - Connection manager is shutting down

You could be facing 2 issues:

You are on a server which has network firewall of some kind, which does not allow you to access the specific IP you are attempting to reach, therefore the connection is getting killed instantly.

Another issue might be that your SSL connection for that IP is invalid, however I think this is less likely, because if there is a problem in SSL, you could get some debug info regarding that.


问:
Zend_Validate good strategy to avoid repetition of code
I'm am currently building two custom validators that extends Zend_Validate_Abstract which are named respectively Lib_Validate_TimeAfter and Lib_Validate_TimeBetween. The names a pretty straight forward, the first one is used to test if a date/datetime/time comes after an other one and the second is used to test if a date/datetime/time comes between two other date/datetime/time.

Both of those validators would rely on the same method named _buildDate($value) which take a value in the form of a datestamp, a hourstamp(either hh:mm or  hh:mm:ss), a timestamp or an ISO_8601 timestamp and convert it in a usable date format.

Since I dont want to repeat myself and copy/paste the method in both of my validator, I was looking for the best way to do it.

The avenues I am looking at right now would be to develop somekind of class helper that my validators would be able to use (kind of messy way of doing things since it add unessesary dependencies) or I could add an other layer of abstraction by building an other validator that validate date/datetime/time and then extend my two validators on that since I could share the method _buildDate($value), but then I don't think I would really need the validator.

So, what would be a good way (I am not really looking for the "Way of the gods" of doing thing) to structure that kind of code to avoid repetition (DRY)?

答: What about a class Lib_Validate_Common which extends Zend_Validate_Abstract which has your common method. And Lib_Validate_TimeAfter and Lib_Validate_TimeBetween extends Lib_Validate_Common .


问:
Python Application Image run in Docker but It does not run in Kubernets
I have been trying to run a Python Django application on Kubernets but not success. The application runs fine in Docker.

This is the yaml Deployment to Kubernets:

```<code>apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  creationTimestamp: "2022-02-06T14:48:45Z"
  generation: 1
  labels:
    app: keyvault
  name: keyvault
  namespace: default
  resourceVersion: "520"
  uid: ccf0e490-517f-4102-b282-2dcd71008948
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: keyvault
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: keyvault
    spec:
      containers:
      - image: david900412/keyvault_web:latest
        imagePullPolicy: Always
        name: keyvault-web-5wrph
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  conditions:
  - lastTransitionTime: "2022-02-06T14:48:45Z"
    lastUpdateTime: "2022-02-06T14:48:45Z"
    message: Deployment does not have minimum availability.
    reason: MinimumReplicasUnavailable
    status: "False"
    type: Available
  - lastTransitionTime: "2022-02-06T14:48:45Z"
    lastUpdateTime: "2022-02-06T14:48:46Z"
    message: ReplicaSet "keyvault-6944b7b468" is progressing.
    reason: ReplicaSetUpdated
    status: "True"
    type: Progressing
  observedGeneration: 1
  replicas: 1
  unavailableReplicas: 1
  updatedReplicas: 1
</code>```

This is the docker compose file I'm using to run the image in Docker:

```<code>version: "3.9"

services:
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
</code>```

This is the docker file I'm using to run the image in Docker:

```<code>FROM python:3.9
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
</code>```

Kubectl describe pod Output:

```<code>Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  51s                default-scheduler  Successfully assigned default/keyvault-6944b7b468-frss4 to minikube
  Normal   Pulled     37s                kubelet            Successfully pulled image "david900412/keyvault_web:latest" in 12.5095594s
  Normal   Pulled     33s                kubelet            Successfully pulled image "david900412/keyvault_web:latest" in 434.2995ms
  Normal   Pulling    17s (x3 over 49s)  kubelet            Pulling image "david900412/keyvault_web:latest"
  Normal   Created    16s (x3 over 35s)  kubelet            Created container keyvault-web-5wrph
  Normal   Started    16s (x3 over 35s)  kubelet            Started container keyvault-web-5wrph
  Normal   Pulled     16s                kubelet            Successfully pulled image "david900412/keyvault_web:latest" in 395.5345ms
  Warning  BackOff    5s (x4 over 33s)   kubelet            Back-off restarting failed container
</code>```

Kubectl log pod Does not show anything :(

Thanks for your help.

答:
This is a community wiki answer posted for better visibility. Feel free to expand it.

Based on the comments, the solution should be as shown below.

Remove volumes definition from the Compose file:

```<code>version: "3.9"

services:
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    ports:
      - "8000:8000"
</code>```

Specify the startup command with CMD for an image in Dockerfile:

```<code>
FROM python:3.9
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
CMD ["python3","manage.py","runserver"]
</code>```

Then translate a Docker Compose file to Kubernetes resources. This can be done with using Kompose or another suitable solution.

Body:
I have been trying to run a Python Django application on Kubernets but not success. The application runs fine in Docker.

This is the yaml Deployment to Kubernets:

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  creationTimestamp: "2022-02-06T14:48:45Z"
  generation: 1
  labels:
    app: keyvault
  name: keyvault
  namespace: default
  resourceVersion: "520"
  uid: ccf0e490-517f-4102-b282-2dcd71008948
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: keyvault
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: keyvault
    spec:
      containers:
      - image: david900412/keyvault_web:latest
        imagePullPolicy: Always
        name: keyvault-web-5wrph
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  conditions:
  - lastTransitionTime: "2022-02-06T14:48:45Z"
    lastUpdateTime: "2022-02-06T14:48:45Z"
    message: Deployment does not have minimum availability.
    reason: MinimumReplicasUnavailable
    status: "False"
    type: Available
  - lastTransitionTime: "2022-02-06T14:48:45Z"
    lastUpdateTime: "2022-02-06T14:48:46Z"
    message: ReplicaSet "keyvault-6944b7b468" is progressing.
    reason: ReplicaSetUpdated
    status: "True"
    type: Progressing
  observedGeneration: 1
  replicas: 1
  unavailableReplicas: 1
  updatedReplicas: 1

This is the docker compose file I'm using to run the image in Docker:

version: "3.9"

services:
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"

This is the docker file I'm using to run the image in Docker:

FROM python:3.9
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

Kubectl describe pod Output:

Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  51s                default-scheduler  Successfully assigned default/keyvault-6944b7b468-frss4 to minikube
  Normal   Pulled     37s                kubelet            Successfully pulled image "david900412/keyvault_web:latest" in 12.5095594s
  Normal   Pulled     33s                kubelet            Successfully pulled image "david900412/keyvault_web:latest" in 434.2995ms
  Normal   Pulling    17s (x3 over 49s)  kubelet            Pulling image "david900412/keyvault_web:latest"
  Normal   Created    16s (x3 over 35s)  kubelet            Created container keyvault-web-5wrph
  Normal   Started    16s (x3 over 35s)  kubelet            Started container keyvault-web-5wrph
  Normal   Pulled     16s                kubelet            Successfully pulled image "david900412/keyvault_web:latest" in 395.5345ms
  Warning  BackOff    5s (x4 over 33s)   kubelet            Back-off restarting failed container

Kubectl log pod Does not show anything :(

Thanks for your help.

Body:
This is a community wiki answer posted for better visibility. Feel free to expand it.

Based on the comments, the solution should be as shown below.

Remove volumes definition from the Compose file:

version: "3.9"

services:
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    ports:
      - "8000:8000"

Specify the startup command with CMD for an image in Dockerfile:

FROM python:3.9
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
CMD ["python3","manage.py","runserver"]

Then translate a Docker Compose file to Kubernetes resources. This can be done with using Kompose or another suitable solution.


问:
Angular 13 and NPM module with moment.js
I have date-picker module for Angular wherein I importing moment.js. Actually I importing NPM package moment-es6 which importing moment.js like this:

```<code>  import * as moment from "moment";
  export default moment;
</code>```

That same issue I have if I import moment.js by my self in my module like this

```<code>  import * as moment from "moment";
</code>```

On Angular 12 it works without any issue. But on Angular 13 when I am trying to use moment.js in this module I got error because moment.js is not imported properly

moment_es6__WEBPACK_IMPORTED_MODULE_0__ is not a function

This issue occurs only when I build module as PROD

My tsconfigs:

```<code>{
  "extends": "../../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../../out-tsc/lib",
    "declarationMap": true,
    "target": "es2015",
    "module": "es2020",
    "declaration": true,
    "inlineSources": true,
    "types": [],
    "lib": [
      "dom",
      "es2018"
    ]
  },
  "angularCompilerOptions": {
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableResourceInlining": true
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}
</code>```

My tsconfig.lib.prod.json

```<code>{
  "extends": "./tsconfig.lib.json",
  "compilerOptions": {
    "declarationMap": false
  },
  "angularCompilerOptions": {
    "compilationMode": "partial"
  }
}
</code>```

Any idea how to fix this. I tried few things but no success

答:
After some research, it turns out that using this import fixes similar problems

```<code>import moment from 'moment'
</code>```

I also found this tricky import:

```<code>import * as temp from 'moment';
const moment = temp["default"];
</code>```

Did you tryed these imports?

Body:
I have date-picker module for Angular wherein I importing moment.js. Actually I importing NPM package moment-es6 which importing moment.js like this:

  import * as moment from "moment";
  export default moment;

That same issue I have if I import moment.js by my self in my module like this

  import * as moment from "moment";

On Angular 12 it works without any issue. But on Angular 13 when I am trying to use moment.js in this module I got error because moment.js is not imported properly

moment_es6__WEBPACK_IMPORTED_MODULE_0__ is not a function

This issue occurs only when I build module as PROD

My tsconfigs:

{
  "extends": "../../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../../out-tsc/lib",
    "declarationMap": true,
    "target": "es2015",
    "module": "es2020",
    "declaration": true,
    "inlineSources": true,
    "types": [],
    "lib": [
      "dom",
      "es2018"
    ]
  },
  "angularCompilerOptions": {
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableResourceInlining": true
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

My tsconfig.lib.prod.json

{
  "extends": "./tsconfig.lib.json",
  "compilerOptions": {
    "declarationMap": false
  },
  "angularCompilerOptions": {
    "compilationMode": "partial"
  }
}

Any idea how to fix this. I tried few things but no success

Body:
After some research, it turns out that using this import fixes similar problems

import moment from 'moment'

I also found this tricky import:

import * as temp from 'moment';
const moment = temp["default"];

Did you tryed these imports?


问:
LOF function in Visual Basic suddenly not working
I am doing some analysis on the US data customer credit card complaints database - see https://catalog.data.gov/dataset/consumer-complaint-database

Saving the file to a csv and running the following code leads to an error

```<code>Sub test()

Dim FolderPath as String
Dim strfilename as String
Dim strtextline as String

strfilename = "C:\Work\VB\complaints.csv"

Open strfilename For Input As #1

strFileContent = Input(LOF(iFile),1)

Close #1

End Sub
</code>```

Runtime error '5'
Invalid Procedure Call or Argument

Is this an error with Visual Basic on my installation? I'm running VBA on Excel with Microsoft Office Professional Plus 2019 with Windows 10.

答:
The file is simply too large to read it in one chunk - its size is 1.5 GB and it holds more than 3 million rows.

You could rewrite your routine to read the file in chunks or row by row, but before you do so, you need to make up your mind what you want to do with the data. You cannot store them in Excel - it's maximum row number is a little bit above 1m (1'048'576 to be precise) and even with this limitation, it's nearly impossible to work. If Excel doesn't crash at all, it will be painfully slow.

My advice would be to store the data in a real database. There are a lot of free db systems around, eg SQL server, PostGres, MariaDB... You need of course learn about databases and SQL to handle that, but I don't see any alternative - Excel, as said, is not build and not capable to handle that amount of data.

Body:
I am doing some analysis on the US data customer credit card complaints database - see https://catalog.data.gov/dataset/consumer-complaint-database

Saving the file to a csv and running the following code leads to an error

Sub test()

Dim FolderPath as String
Dim strfilename as String
Dim strtextline as String

strfilename = "C:\Work\VB\complaints.csv"

Open strfilename For Input As #1

strFileContent = Input(LOF(iFile),1)

Close #1

End Sub

Runtime error '5'
Invalid Procedure Call or Argument

Is this an error with Visual Basic on my installation? I'm running VBA on Excel with Microsoft Office Professional Plus 2019 with Windows 10.


问:
Convert date to string in Angular
I'm working on an Angular webui project. Currently I have to get a value from a data-document.json which is of type date but I need to display it as a string. How would I be able to achieve this?

```<code>"FACD_Dispatch_DateTime": "2022-01-19T16:46:03.959",
</code>```

this is the way that I've been trying:

```<code>map(([d]) => {

           let myDate: string;
          if (d?.value) {
            myDate = d.value;
          }
</code>```

but terminal returns the error: Type 'Date' is not assignable to type 'string'

答:
well "FACD_Dispatch_DateTime": "2022-01-19T16:46:03.959" is not a Date, but a string. Anyway:

let myDate: Date;
if (d?.value) {
  myDate = d.value;
}
```
<p>then you can display it in your HTML:</p>
<pre class="lang-html prettyprint-override"><code><h1> Day: {{myDate | date:'dd.MM.yyyy'}} Time: {{myDate | date:'HH:mm'}}</h1>
</code>```

Title: Convert date to string in Angular

Body:
I'm working on an Angular webui project. Currently I have to get a value from a data-document.json which is of type date but I need to display it as a string. How would I be able to achieve this?

"FACD_Dispatch_DateTime": "2022-01-19T16:46:03.959",

this is the way that I've been trying:

map(([d]) => {

           let myDate: string;
          if (d?.value) {
            myDate = d.value;
          }

but terminal returns the error: Type 'Date' is not assignable to type 'string'

Body:
well "FACD_Dispatch_DateTime": "2022-01-19T16:46:03.959" is not a Date, but a string. Anyway:

let myDate: Date;
if (d?.value) {
  myDate = d.value;
}

then you can display it in your HTML:

<h1> Day: {{myDate | date:'dd.MM.yyyy'}} Time: {{myDate | date:'HH:mm'}}</h1>


问:
is it corrent that using a meaningless leading zero to encode positive ASN.1 INTEGER?
Are these encodings same in ASN.1 INTEGER type?

encoding decimal 10

02 01 0A

02 02 00 0A

02 03 00 00 0A

...

答:
I assume you are using BER.  The BER encoding for an INTEGER uses the smallest possible number of octets.  The second and third encodings would be incorrect.

See X.690 8.3


问:
How to render inner Css - Angular
I have an object "Content" contains two properties:

```<code>Content:{
html:string;
css:string
}
</code>```

and I need to render a div depending on this object, for the html I could do that using:

```<code><div [innnerHtml]="Content.html"></div>
</code>```

but I couldn't render the css of the object.
Content example:

```<code>Content:{
html:"<p>test rendering the object</p> <br> <div class="div1"></div>",
css:"p{color:red} .div1{background-color:black}"
}
</code>```

答:
You can use ngStyle tag directives.

Ex:

```<code><div [ngStyle]='style.css' [innnerHtml]="Content.html"></div>
</code>```

Title: How to render inner Css - Angular

Body:
I have an object "Content" contains two properties:

Content:{
html:string;
css:string
}

and I need to render a div depending on this object, for the html I could do that using:

but I couldn't render the css of the object.
Content example:

Content:{
html:"
test rendering the object

",
css:"p{color:red} .div1{background-color:black}"
}

Body:
You can use ngStyle tag directives.

Ex:

<div [ngStyle]='style.css' [innnerHtml]="Content.html"></div>


问:
Export settings of OctoberCMS Theme
Im trying to export my theme from OctoberCMS.
So I went to Settings->Front-end theme -> Manage and Export

The problem is that all my settings are saved in the database instead in the static-pages.yml, main-menu.yaml and so on. But the content-files are OK in the static-pages folder.

Is there are possibility to write all settings into the filesystem from the database?

答:
Hmm it will be a little tricky,  there is one option you can add settings to your theme.yaml file and then just use them from there

you can extend theme configuration settings which are written on theme.yaml file and it can be exported.

you can read the entire article and watch a video of it here
ref: Extend And Export OctoberCMS Theme Settings

<?php namespace Hardiksatasiya\So;

use System\Classes\PluginBase;
// ...

class Plugin extends PluginBase
{
  public function boot() {
    \Event::listen('backend.form.extendFieldsBefore', function ($formWidget) {
      // if its not theme modal do not proceed
      if (!$formWidget->model instanceof \Cms\Classes\Theme) {
          return;
      }

      // Here you can't use addFields() because it will throw you an exception because the form is not yet created
      // and it does not have tabs and fields

      // add  navigation_text field
      $formWidget->fields['navigation_text'] = [
          'label' => 'Navigation Text',
          'comment' => 'Site should show navigation text on navigation menu.',
          'span' => 'left'

      ];

      // add another primary_color field
      $formWidget->fields['primary_color'] = [
          'label' => 'Primary Color',
          'comment' => 'Select theme primary color.',
          'type' => 'colorpicker',
          'span' => 'right'
      ];
    });
  }
  // ...
```
<blockquote>
<p>field will look like this</p>
</blockquote>
<p><img src="https://i.stack.imgur.com/FoDNV.jpg" alt="theme-field-extension" /></p>
<blockquote>
<p>Your <code>yaml</code> file will look like this</p>
</blockquote>
<pre class="lang-yaml prettyprint-override"><code>navigation_text: 'My website navigation' #new field
primary_color: '#2ecc71'                 #new field
name: Demo
description: 'Some description.'
author: OctoberCMS
homepage: 'http://octobercms.com'
code: 'hardik.satasiya'
</code>```

This is how you can use these config values

use Cms\Classes\Theme;

// get your current active theme
$theme = Theme::getActiveTheme();

// get your config value
$navigationText = $theme->getConfigValue('navigation_text', 'Default value');
$primaryColor = $theme->getConfigValue('primary_color', '#fff');

// $navigationText => 'My website navigation'
// $primaryColor => '#2ecc71'
```

if any doubt please comment.

Title: Export settings of OctoberCMS Theme

Body:
Hmm it will be a little tricky,  there is one option you can add settings to your theme.yaml file and then just use them from there

you can extend theme configuration settings which are written on theme.yaml file and it can be exported.

you can read the entire article and watch a video of it here
ref: Extend And Export OctoberCMS Theme Settings

<?php namespace Hardiksatasiya\So;

use System\Classes\PluginBase;
// ...

class Plugin extends PluginBase
{
  public function boot() {
    \Event::listen('backend.form.extendFieldsBefore', function ($formWidget) {
      // if its not theme modal do not proceed
      if (!$formWidget->model instanceof \Cms\Classes\Theme) {
          return;
      }

      // Here you can't use addFields() because it will throw you an exception because the form is not yet created
      // and it does not have tabs and fields

      // add  navigation_text field
      $formWidget->fields['navigation_text'] = [
          'label' => 'Navigation Text',
          'comment' => 'Site should show navigation text on navigation menu.',
          'span' => 'left'

      ];

      // add another primary_color field
      $formWidget->fields['primary_color'] = [
          'label' => 'Primary Color',
          'comment' => 'Select theme primary color.',
          'type' => 'colorpicker',
          'span' => 'right'
      ];
    });
  }
  // ...

field will look like this

Your yaml file will look like this

navigation_text: 'My website navigation' #new field
primary_color: '#2ecc71'                 #new field
name: Demo
description: 'Some description.'
author: OctoberCMS
homepage: 'http://octobercms.com'
code: 'hardik.satasiya'

This is how you can use these config values

use Cms\Classes\Theme;

// get your current active theme
$theme = Theme::getActiveTheme();

// get your config value
$navigationText = $theme->getConfigValue('navigation_text', 'Default value');
$primaryColor = $theme->getConfigValue('primary_color', '#fff');

// $navigationText => 'My website navigation'
// $primaryColor => '#2ecc71'

if any doubt please comment.


问:
Get a hard-coded value using combination of multiple keys
I've to store hard-coded value in my environment files like this:

folder.canada.6m.ind=150992762918

folder.canada.9m.group=150992760518

folder.usa.1m.ind=150992762995

There are 3 parameters (String country, String months, String category) which I receive from the end user and I've to pick the corresponding value from env files.

I can do it using brute force like,

```<code>if(country.equals(canada) && months.equals(6m) && category.equals(ind)) {
return folder.canada.6m.ind;
}
</code>```

There are other ways to do it using if-else as well but I have 100's of these values so I don't think the best way to solve this problem is using if-else.
What would be the best data structure or method to solve this problem?

I'm using spring-boot in Java.

答:
Spring boot can put your properties into a map. Let's have a look at the following class:

@Configuration
@ConfigurationProperties(prefix = "")
public class FolderConfig {

    private Map<String, String> folder = new HashMap<>();

    public void setFolder(Map<String, String> folder) {
        this.folder = folder;
    }

    public String getValue(String country, String month, String category) {
        String key = String.format("%s.%s.%s", country, month, category);
        return folder.get(key);
    }
}
```
<p>The naming of the map is important, because it is used as prefix of your properties keys! This means, the map <code>folder</code> has the following values:</p>
```canada.6m.ind=150992762918
canada.9m.group=150992760518
usa.1m.ind=150992762995
```

You see your keys don't start with folder!

Maybe you should think about throwing an additional exception, if the key doesn't exists.

Body:
I've to store hard-coded value in my environment files like this:

folder.canada.6m.ind=150992762918

folder.canada.9m.group=150992760518

folder.usa.1m.ind=150992762995

There are 3 parameters (String country, String months, String category) which I receive from the end user and I've to pick the corresponding value from env files.

I can do it using brute force like,

if(country.equals(canada) && months.equals(6m) && category.equals(ind)) {
return folder.canada.6m.ind;
}

There are other ways to do it using if-else as well but I have 100's of these values so I don't think the best way to solve this problem is using if-else.
What would be the best data structure or method to solve this problem?

I'm using spring-boot in Java.

Body:
Spring boot can put your properties into a map. Let's have a look at the following class:

@Configuration
@ConfigurationProperties(prefix = "")
public class FolderConfig {

    private Map<String, String> folder = new HashMap<>();

    public void setFolder(Map<String, String> folder) {
        this.folder = folder;
    }

    public String getValue(String country, String month, String category) {
        String key = String.format("%s.%s.%s", country, month, category);
        return folder.get(key);
    }
}

The naming of the map is important, because it is used as prefix of your properties keys! This means, the map folder has the following values:

canada.6m.ind=150992762918
canada.9m.group=150992760518
usa.1m.ind=150992762995

You see your keys don't start with folder!

Maybe you should think about throwing an additional exception, if the key doesn't exists.


问:
JAVA combobox blank spaces
I got a combobox filled with items.

Whenever I delete one of the items, the value is deleted but not the
blank space inside the combobox?

How do i fix this?

this is javafx :)

If i would have 10 items inside my combobox and delete them all I would have 10 blank spaces ..

```<code> @FXML
public void toevoegenPloeg(ActionEvent event) throws ApplicationException, DBException {

    //verbinding met transactielaag
    PloegTrans pt = new PloegTrans();

    lblCorrect.setText("");
    lblError.setText("");

    //kijken of er een niveau geselecteerd is (must)
    if(cboNiveau.getSelectionModel().getSelectedItem() != null){
        taPloegen.setVisible(true);
        //niveau ophalen uit combobox
        String niveau = cboNiveau.getSelectionModel().getSelectedItem().name();

        //verbinding met db klasses
        PloegDB pdb = new PloegDB();
        PersoonDB pb = new PersoonDB();

        //ploegnaam berekenen
        Integer aantal = pdb.zoekAantalPloegenPerNiveau(niveau);

        //als aantal groter is dan " Z " dan error geven
        if (aantal+1 < 27) {
            String ploegnaam = niveau + getLetter(aantal+1);;
            try{

                //indien geen trainer geselectteerd dan ploeg maken zonder trainer
                if(cboTrainer.getSelectionModel().getSelectedItem() == null) {

                    //gegevens setten
                    PloegBag pr = new PloegBag();
                    pr.setNaam(ploegnaam);
                    pr.setNiveau(niveau);
                    int ploegID = pt.toevoegenPloegZonderTrainer(pr);

                    pr.setId(ploegID);

                    lblCorrect.setText("ploeg werd aangemaakt");

                    //toevoegen gegevens en combobox op leeg zetten
                    taPloegen.getItems().add(pr);
                    cboNiveau.getSelectionModel().select(null);
                    iniTabel();
                }

                // anders gaan we een ploeg maken met een trainer
                else {
                    //trainerid berkenenen
                    Integer trainerId =  cboTrainer.getSelectionModel().getSelectedItem().getId();

                    PloegBag pr = new PloegBag();
                    PersoonBag pa = cboTrainer.getSelectionModel().getSelectedItem();

                    //setters voor het persoonbag
                    pr.setNaam(ploegnaam);
                    pr.setNiveau(niveau);
                    pr.setTrainer_id(trainerId);

                    int ploegID = pt.toevoegenPloeg(pr);
                    pr.setId(ploegID);

                    lblCorrect.setText("Ploeg werd aangemaakt");

                    //toevoegen aan tableview en comboboxes leegmaken
                    taPloegen.getItems().add(pr);
                    cboNiveau.getSelectionModel().select(null);
                    cboTrainer.getSelectionModel().select(null);

                    //trainer heeft nu een ploeg dus erwijderen wehem uit de combobox
                    cboTrainer.getItems().remove(pa);
                    iniTabel();
                }
            } catch (DBException ae){
                lblError.setText("Onherstelbare fout: " + ae.getMessage());
            }
             catch (ApplicationException ae){
                lblError.setText(ae.getMessage());
            }
        } else {
            lblError.setText("Ploegenniveau zit vol");
        }
    } else {
        lblError.setText("Geen niveau geselecteerd");
    }
}

 private void iniComboTrainer(){
    PersoonDB pdb = new PersoonDB();

    try{
        ArrayList<PersoonBag> persoonlijst = pdb.zoekAlleOpenTrainers();
        for(PersoonBag pb : persoonlijst){
            cboTrainer.getItems().add(pb);
        }
    } catch (ApplicationException ae) {
        lblError.setText(ae.getMessage());
    } catch (DBException ae) {
        lblError.setText("onherstelbare fout: " + ae.getMessage());
    }
}
</code>```

EDIT: i still have'nt found the issue.. i tried all options.. here's what I mean when the item is deleted the blank space still exists.

edit: whenever i swap to another page and go back the blank spaces are gone.. but not when i'm on the same page

答:
make clear() on items list and fill it with new list.

Example:
Combo.getItems().clear();
Combo.getItems() .addAll(newItemList);

Title: JAVA combobox blank spaces

Body:
I got a combobox filled with items.

Whenever I delete one of the items, the value is deleted but not the
blank space inside the combobox?

How do i fix this?

this is javafx :)

If i would have 10 items inside my combobox and delete them all I would have 10 blank spaces ..

 @FXML
public void toevoegenPloeg(ActionEvent event) throws ApplicationException, DBException {

    //verbinding met transactielaag
    PloegTrans pt = new PloegTrans();

    lblCorrect.setText("");
    lblError.setText("");

    //kijken of er een niveau geselecteerd is (must)
    if(cboNiveau.getSelectionModel().getSelectedItem() != null){
        taPloegen.setVisible(true);
        //niveau ophalen uit combobox
        String niveau = cboNiveau.getSelectionModel().getSelectedItem().name();

        //verbinding met db klasses
        PloegDB pdb = new PloegDB();
        PersoonDB pb = new PersoonDB();

        //ploegnaam berekenen
        Integer aantal = pdb.zoekAantalPloegenPerNiveau(niveau);

        //als aantal groter is dan " Z " dan error geven
        if (aantal+1 < 27) {
            String ploegnaam = niveau + getLetter(aantal+1);;
            try{

                //indien geen trainer geselectteerd dan ploeg maken zonder trainer
                if(cboTrainer.getSelectionModel().getSelectedItem() == null) {

                    //gegevens setten
                    PloegBag pr = new PloegBag();
                    pr.setNaam(ploegnaam);
                    pr.setNiveau(niveau);
                    int ploegID = pt.toevoegenPloegZonderTrainer(pr);

                    pr.setId(ploegID);

                    lblCorrect.setText("ploeg werd aangemaakt");

                    //toevoegen gegevens en combobox op leeg zetten
                    taPloegen.getItems().add(pr);
                    cboNiveau.getSelectionModel().select(null);
                    iniTabel();
                }

                // anders gaan we een ploeg maken met een trainer
                else {
                    //trainerid berkenenen
                    Integer trainerId =  cboTrainer.getSelectionModel().getSelectedItem().getId();

                    PloegBag pr = new PloegBag();
                    PersoonBag pa = cboTrainer.getSelectionModel().getSelectedItem();

                    //setters voor het persoonbag
                    pr.setNaam(ploegnaam);
                    pr.setNiveau(niveau);
                    pr.setTrainer_id(trainerId);

                    int ploegID = pt.toevoegenPloeg(pr);
                    pr.setId(ploegID);

                    lblCorrect.setText("Ploeg werd aangemaakt");

                    //toevoegen aan tableview en comboboxes leegmaken
                    taPloegen.getItems().add(pr);
                    cboNiveau.getSelectionModel().select(null);
                    cboTrainer.getSelectionModel().select(null);

                    //trainer heeft nu een ploeg dus erwijderen wehem uit de combobox
                    cboTrainer.getItems().remove(pa);
                    iniTabel();
                }
            } catch (DBException ae){
                lblError.setText("Onherstelbare fout: " + ae.getMessage());
            }
             catch (ApplicationException ae){
                lblError.setText(ae.getMessage());
            }
        } else {
            lblError.setText("Ploegenniveau zit vol");
        }
    } else {
        lblError.setText("Geen niveau geselecteerd");
    }
}

 private void iniComboTrainer(){
    PersoonDB pdb = new PersoonDB();

    try{
        ArrayList<PersoonBag> persoonlijst = pdb.zoekAlleOpenTrainers();
        for(PersoonBag pb : persoonlijst){
            cboTrainer.getItems().add(pb);
        }
    } catch (ApplicationException ae) {
        lblError.setText(ae.getMessage());
    } catch (DBException ae) {
        lblError.setText("onherstelbare fout: " + ae.getMessage());
    }
}

EDIT: i still have'nt found the issue.. i tried all options.. here's what I mean when the item is deleted the blank space still exists.

edit: whenever i swap to another page and go back the blank spaces are gone.. but not when i'm on the same page


问:
Slide In button effect of List View item for Android
I'm porting an iPhone app into android app and one of the difficulties is recreating functionalities that are native to iPhone.

I found a native functionality of iPhone:
When user execute slide touch on a listed item in list view, a delete button appears.

Is there a version for this in android?
Can it be used and reused/customized?

答:
This is just a bit more complicated to achieve.  This is what I would do talking from a higher level.

Create a custom ViewGroup/Layout to hold a list item.  Inside this layout you have your text lines images or what ever you have and also the delete button.  You also here listen for gestures to hide or unhide the delete button.

In your list adapter you are going to need to keep track of which item is showing the delete button and which is not.  Also, you are going to need to apply a click listener to each of the list item delete buttons.  Every time you assign these states on the list item you should setTag(...) and store the list item position so that when it's clicked you can tell which item number must be deleted.

After deleting you must refresh the list in order for it to take effect.  Depending on what type of adapter you are using that's going to determine how you refresh the adapter.

Hopefully this makes some sense.  But I definitely think this is the easiest way since I've done this a couple times with similar functionality.


问:
why the mobile media query is not working on mobile
I know this is a stupid question, but I'm having trouble with the small screen media query. I gave the image a class, so it should work. Also, when I tried to add an id, it didn't work, so is there something wrong with my code or the media query thing? Any assistance or advice would be greatly appreciated.

@media only screen and (max-width : 600px){

.mondaycont .monday{
  position: relative;
  width: 20em;
  margin-top: 10px;

}

}

.mondaycont{

  width: 84%;
}

.mondaycont .monday{
  position: relative;
  width: 40em;
  margin-top: 20px;

}

.mondaytext{
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  color: white;
  margin-top: 50px;
  position: relative;

}

.mondaytextbold{
  font-family: 'Inter', sans-serif;
  font-weight: bold;
  color: white;
  margin-top: 10px;
  position: relative;

}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ERROR 404</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="stylesheet" href="./css/style.css">
</head>
<body>
    <style>body{background-color: #262626;}</style>
    <div class="container text-center"><p class=" mondaytext">This page feels like a monday...</p>
    <p class=" mondaytextbold">Go Home</p> </div>

    <div class="container-fluid mondaycont text-center">
        <img class="img-fluid monday" src="./images/ERROR404.png" alt="404"></div>
</body>
</html></code>```

答:
Your media query is followed by a declaration that applies to all resolutions, overwriting your media query width definition. Media queries do not affect specificity, so the normal "last rule wins" applies.

Exchange the position of these two rules:

.mondaycont .monday {
  position: relative;
  width: 40em;
  margin-top: 20px;
}

@media only screen and (max-width: 600px) {
  .mondaycont .monday {
    position: relative;
    width: 20em;
    margin-top: 10px;
  }
}

.mondaycont {
  width: 84%;
}

.mondaytext {
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  color: white;
  margin-top: 50px;
  position: relative;
}

.mondaytextbold {
  font-family: 'Inter', sans-serif;
  font-weight: bold;
  color: white;
  margin-top: 10px;
  position: relative;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>ERROR 404</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
  <link rel="stylesheet" href="./css/style.css">
</head>

<body>
  <style>
    body {
      background-color: #262626;
    }
  </style>
  <div class="container text-center">
    <p class=" mondaytext">This page feels like a monday...</p>

      <p class=" mondaytextbold">Go Home</p>

  </div>

  <div class="container-fluid mondaycont text-center">
    <img class="img-fluid monday" src="./images/ERROR404.png" alt="404"></div>
</body>

</html></code>```

Body:
I know this is a stupid question, but I'm having trouble with the small screen media query. I gave the image a class, so it should work. Also, when I tried to add an id, it didn't work, so is there something wrong with my code or the media query thing? Any assistance or advice would be greatly appreciated.

@media only screen and (max-width : 600px){

.mondaycont .monday{
  position: relative;
  width: 20em;
  margin-top: 10px;

}

}

.mondaycont{

  width: 84%;
}

.mondaycont .monday{
  position: relative;
  width: 40em;
  margin-top: 20px;

}

.mondaytext{
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  color: white;
  margin-top: 50px;
  position: relative;

}

.mondaytextbold{
  font-family: 'Inter', sans-serif;
  font-weight: bold;
  color: white;
  margin-top: 10px;
  position: relative;

}

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ERROR 404</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="stylesheet" href="./css/style.css">

This page feels like a monday...

Go Home

Body:
Your media query is followed by a declaration that applies to all resolutions, overwriting your media query width definition. Media queries do not affect specificity, so the normal "last rule wins" applies.

Exchange the position of these two rules:

.mondaycont .monday {
  position: relative;
  width: 40em;
  margin-top: 20px;
}

@media only screen and (max-width: 600px) {
  .mondaycont .monday {
    position: relative;
    width: 20em;
    margin-top: 10px;
  }
}

.mondaycont {
  width: 84%;
}

.mondaytext {
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  color: white;
  margin-top: 50px;
  position: relative;
}

.mondaytextbold {
  font-family: 'Inter', sans-serif;
  font-weight: bold;
  color: white;
  margin-top: 10px;
  position: relative;
}

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>ERROR 404</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
  <link rel="stylesheet" href="./css/style.css">
</head>

<body>
  <style>
    body {
      background-color: #262626;
    }
  </style>
  <div class="container text-center">
    <p class=" mondaytext">This page feels like a monday...</p>
    <a href="./index.html">
      <p class=" mondaytextbold">Go Home</p>
    </a>
  </div>

  <div class="container-fluid mondaycont text-center">
    <img class="img-fluid monday" src="./images/ERROR404.png" alt="404"></div>
</body>

</html>


问:
AWS Redshift - Failed to incorporate external table into local catalog
Having a problem with one of our external tables in redshift.

We have over 300 tables in AWS Glue which have been added to our redshift cluster as an external schema called events. Most of the tables in events can be queries fine. But when querying one of the tables called item_loaded  we get the following error;

```<code>select * from events.item_loaded limit 1;
ERROR:  XX000: Failed to incorporate external table "events"."item_loaded" into local catalog.
LOCATION:  localize_external_table, /home/ec2-user/padb/src/external_catalog/external_catalog_api.cpp:358
</code>```

What's weird is that they are in the catalog;

```<code>select *
from SVV_EXTERNAL_TABLES
where tablename = 'item_loaded';

-[ RECORD 1 ]-----+------------------------------------------
schemaname        | events
tablename         | item_loaded
location          | s3://my_bucket/item_loaded
input_format      | org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
output_format     | org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
serialization_lib | org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
serde_parameters  | {"serialization.format":"1"}
compressed        | 0
parameters        | {"EXTERNAL":"TRUE","parquet.compress":"SNAPPY","transient_lastDdlTime":"1504792238"}
</code>```

AFAICT, this table is configured the exact same way as the other tables in the same schema which are working fine. I've tried recreating a new external schema pointing to the same AWS Glue database but the same issue occurs.

What else could I potentially check? Is there anything that could occur which would cause a table to removed from the catalog?

答:
it can also happen if there are typos in the config.
for ex following fails:

```<code>SECRET_ARN ' arn:aws:secretsmanager:us-east-1:123:secret:stage/data/redshift-rds'
</code>```

and following works

```<code>SECRET_ARN 'arn:aws:secretsmanager:us-east-1:123:secret:stage/data/redshift-rds'
</code>```

Note additional space at the beginning of arn

Body:
Having a problem with one of our external tables in redshift.

We have over 300 tables in AWS Glue which have been added to our redshift cluster as an external schema called events. Most of the tables in events can be queries fine. But when querying one of the tables called item_loaded  we get the following error;

select * from events.item_loaded limit 1;
ERROR:  XX000: Failed to incorporate external table "events"."item_loaded" into local catalog.
LOCATION:  localize_external_table, /home/ec2-user/padb/src/external_catalog/external_catalog_api.cpp:358

What's weird is that they are in the catalog;

select *
from SVV_EXTERNAL_TABLES
where tablename = 'item_loaded';

-[ RECORD 1 ]-----+------------------------------------------
schemaname        | events
tablename         | item_loaded
location          | s3://my_bucket/item_loaded
input_format      | org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
output_format     | org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
serialization_lib | org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
serde_parameters  | {"serialization.format":"1"}
compressed        | 0
parameters        | {"EXTERNAL":"TRUE","parquet.compress":"SNAPPY","transient_lastDdlTime":"1504792238"}

AFAICT, this table is configured the exact same way as the other tables in the same schema which are working fine. I've tried recreating a new external schema pointing to the same AWS Glue database but the same issue occurs.

What else could I potentially check? Is there anything that could occur which would cause a table to removed from the catalog?

Body:
it can also happen if there are typos in the config.
for ex following fails:

SECRET_ARN ' arn:aws:secretsmanager:us-east-1:123:secret:stage/data/redshift-rds'

and following works

SECRET_ARN 'arn:aws:secretsmanager:us-east-1:123:secret:stage/data/redshift-rds'

Note additional space at the beginning of arn