Open kirpy0x opened 2 months ago
HI @kirpy0x thank you for the report. Based on the log, it seems strfry were not started in docker container when you run that. Would you mind share more detail information?
docker run --init --env-file .env -p 7860:7860 -it ghcr.io/atrifat/nostr-filter-relay:v0.4.1
Ubuntu 22.04 amd64
If you have detail steps (including all cli command) then i will try to reproduce and take a look on this issue.
main, dev, latest, and 0.4.0 With the above result. 0.3.0 didn't have the above error but still replied 502 when I tried to query it. Just tried 0.4.1 and same result
Originally I was trying docker compose but into troubleshooting I just started using docker run --init --env-file .env -p 7860:7860 -it ghcr.io/atrifat/nostr-filter-relay:v0.4.1
and trying different images.
I've also simplified the config to only modified the hex pub/sec and setting the detectors to false.
OS: Ubuntu 22.04.5 LTS - x86_64 - Docker version 27.2.1, build 9e34c9b
I haven't tried without docker. I can maybe try tomorrow.
Looks like it may be a strfry thing. Tried running strfry manually without docker and got error - "strfry error: Unable to set NOFILES limit to 1000000, exceeds max of 524288"
Updated strfry.conf nofiles to 524288.
Ran again with no error, netstat shows it's listening on 7777, however still not able to query it. tried disabling firewall momentarily.
While I still have more troubleshooting to do on strfry's side it may be a good idea to add an option for the NOFILES property for strfry.conf in the .env.
Looks like others ran in to this in strfry's issues.
Looks like it may be a strfry thing. Tried running strfry manually without docker and got error - "strfry error: Unable to set NOFILES limit to 1000000, exceeds max of 524288"
Updated strfry.conf nofiles to 524288.
Ran again with no error, netstat shows it's listening on 7777, however still not able to query it. tried disabling firewall momentarily.
While I still have more troubleshooting to do on strfry's side it may be a good idea to add an option for the NOFILES property for strfry.conf in the .env.
Looks like others ran in to this in strfry's issues.
I think, the issue might be related to OS file limit setting or Docker config that were set in your computer/devices.
Have you set/modify something that related to OS ulimit setting in your /etc/docker/daemon.json
?
Something like this probably?
{
"default-ulimits": {
"nofile": {
"hard": 524288,
"soft": 524288
}
}
}
If you have setting like this then it might prevent any container app set their own OS file descriptor limit. By default docker regular/fresh installation (Docker CLI, not Docker Desktop version) won't have anything in /etc/docker/daemon.json
.
Also, do you modify something in /etc/security/limits.conf
? What is the value of your /etc/security/limits.conf
config?
I have already tested this using default docker installation and default config without any OS ulimit related changes in /etc/docker/daemon.json
and /etc/security/limits.conf
, it run properly in PC (Ubuntu 22.04 x86_64), Laptop (Ubuntu 24.04 x86_64), and VPS Server (Debian 12 x86_64). So, i think this is only happened in those cases when default config changes with some OS ulimit setting. strfry.conf that were included in nostr-filter-relay is based on default config of hoytech/strfry.
Oh my gosh please forgive me. The reason it wasn't connecting was due to my mixing up my servers IPs! I'm so sorry!
The error listed still happens when the container starts up, however I'm not sure how much it's affecting the functionality. My Query and shows there shows there are equal amount of kind 1985's to 1's.
I can only think the strfry error was only occurring when not in Docker? I exec'd to the docker container and confirmed nofiles limit is set to 1000000 while it's seemingly working when in Docker.
daemon.json { "log-driver": "json-file", "log-opts": { "max-file": "10", "max-size": "100m" } } limits
#
The strfry connection error only happens at startup of the container.
Oh my gosh please forgive me. The reason it wasn't connecting was due to my mixing up my servers IPs! I'm so sorry!
The error listed still happens when the container starts up, however I'm not sure how much it's affecting the functionality. My Query and shows there shows there are equal amount of kind 1985's to 1's.
I can only think the strfry error was only occurring when not in Docker? I exec'd to the docker container and confirmed nofiles limit is set to 1000000 while it's seemingly working when in Docker.
daemon.json { "log-driver": "json-file", "log-opts": { "max-file": "10", "max-size": "100m" } } limits #
soft core 0 #root hard core 100000 # hard rss 10000 #@Student hard nproc 20 #@faculty soft nproc 20 #@faculty hard nproc 50 #ftp hard nproc 0 #ftp - chroot /ftp #@Student - maxlogins 4
The strfry connection error only happens at startup of the container.
Based on this, you only have problem when not running strfry in nostr-filter-relay docker?
If you want to run manually strfry on your machine, you can probably edit strfry.conf and change it according to your own machine limit.
I have tried this configuration .env
in my PC and running properly. Can you please try this config and save as your .env
without changing anything?
NODE_ENV=production
# ENV variable for nostr-monitoring-tool. Check atrifat/nostr-monitoring-tool github for more information.
# (Optional. Default: true) Set whether to publish NIP-32 classification event (kind: 1985)
ENABLE_NIP_32_CLASSIFICATION_EVENT=true
# (Optional. Default: true) (Deprecated) Set whether to publish legacy classification event (kind: 9978)
ENABLE_LEGACY_CLASSIFICATION_EVENT=true
ENABLE_NSFW_CLASSIFICATION=false
NSFW_DETECTOR_ENDPOINT=http://localhost:8082/predict
NSFW_DETECTOR_TOKEN=
ENABLE_LANGUAGE_DETECTION=false
LANGUAGE_DETECTOR_ENDPOINT=http://localhost:5000/detect
LANGUAGE_DETECTOR_TOKEN=
LANGUAGE_DETECTOR_TRUNCATE_LENGTH=350
ENABLE_HATE_SPEECH_DETECTION=false
# (Required if ENABLE_HATE_SPEECH_DETECTION == true) set this to your own hate-speech-detector-api instance (https://github.com/atrifat/hate-speech-detector-api)
HATE_SPEECH_DETECTOR_ENDPOINT=http://localhost:8083/predict
# (Optional) set this to your own hate-speech-detector-api api_key if required
HATE_SPEECH_DETECTOR_TOKEN=
# (Default: 350) Set to 0 if you don't want to truncate text, or set to any positive number to truncate the text characters
HATE_SPEECH_DETECTOR_TRUNCATE_LENGTH=350
ENABLE_SENTIMENT_ANALYSIS=false
# (Required if ENABLE_SENTIMENT_ANALYSIS == true) set this to your own sentiment-analysis-api instance (https://github.com/atrifat/sentiment-analysis-api)
SENTIMENT_ANALYSIS_ENDPOINT=http://localhost:8084/predict
# (Optional) set this to your own sentiment-analysis-api api_key if required
SENTIMENT_ANALYSIS_TOKEN=
# (Default: 350) Set to 0 if you don't want to truncate text, or set to any positive number to truncate the text characters
SENTIMENT_ANALYSIS_TRUNCATE_LENGTH=350
ENABLE_TOPIC_CLASSIFICATION=false
# (Required if ENABLE_TOPIC_CLASSIFICATION == true) set this to your own topic-classification-api instance (https://github.com/atrifat/topic-classification-api)
TOPIC_CLASSIFICATION_ENDPOINT=http://localhost:8085/predict
# (Optional) set this to your own topic-classification-api api_key if required
TOPIC_CLASSIFICATION_TOKEN=
# (Default: 350) Set to 0 if you don't want to truncate text, or set to any positive number to truncate the text characters
TOPIC_CLASSIFICATION_TRUNCATE_LENGTH=350
# (Required for classification filtering)
# Temporary uses "1" as secret key for debugging
NOSTR_MONITORING_BOT_PRIVATE_KEY=1
RELAYS_SOURCE=wss://relay.nostr.band
RELAYS_TO_PUBLISH=ws://127.0.0.1:7777
DELAYS_BEFORE_PUBLISHING_NOTES=1000
ENABLE_MQTT_PUBLISH=false
MQTT_BROKER_TO_PUBLISH=
# ENV variable for nostr-filter. Check atrifat/nostr-filter for more information.
UPSTREAM_HTTP_URL=http://127.0.0.1:7777
UPSTREAM_WS_URL=ws://127.0.0.1:7777
# (Required for classification filtering)
# 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 is the public key of "1"
NOSTR_MONITORING_BOT_PUBLIC_KEY=79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
# (Optional) if it is not empty, it will accept events only from whitelisted pubkey. It can be set with NOSTR_MONITORING_BOT_PUBLIC_KEY value to make nostr-filter as read-only relay.
WHITELISTED_PUBKEYS=
LISTEN_PORT=7860
# (Optional) Set true to enable forwarding of request headers to upstream server, useful if relays behind reverse proxy
ENABLE_FORWARD_REQ_HEADERS=true
# (Default: true) Use NIP-32 Event Format (kind: 1985) or Deprecated Legacy Format (kind: 9978). Legacy format will be fully replaced by NIP-32 event format in the future.
USE_NIP_32_EVENT_FORMAT=true
# Set maximum websocket server payload size (maximum allowed message size) in bytes
MAX_WEBSOCKET_PAYLOAD_SIZE=1000000
# Set maximum number of parallel concurrency limit when requesting classification events to relay
RELAY_REQUEST_CONCURRENCY_LIMIT=10
# Set true to enable rate limit for number of websocket message
ENABLE_RATE_LIMIT=false
# Set to "IP" to rate limit based on IP addresses otherwise using socketId
RATE_LIMIT_KEY="IP"
# Maximum number of websocket message (REQ, EVENT, etc) per second per IP/socketId
MAX_WEBSOCKET_MESSAGE_PER_SECOND=10
# Maximum number of websocket message (REQ, EVENT, etc) per minute per IP/socketId
MAX_WEBSOCKET_MESSAGE_PER_MINUTE=1000
# (Optional. Default: sfw. Options: all, sfw, partialsfw, and nsfw) Filter hate speech (toxic comment).
DEFAULT_FILTER_CONTENT_MODE=sfw
# (Optional. Default: 75, Options: 0-100) Default minimum probability/confidence score to determine the classification of nsfw content
DEFAULT_FILTER_NSFW_CONFIDENCE=75
# (Optional. Default: all. Multiple Options: all, or other language code)
DEFAULT_FILTER_LANGUAGE_MODE=all
# (Optional. Default: 15. Options: 0-100) Default minimum probability/confidence score to determine the classification of language
DEFAULT_FILTER_LANGUAGE_CONFIDENCE=15
# (Optional. Default: no. Options: all, no, yes) Filter hate speech (toxic comment). "all" will disable filtering, "no" will filter out any detected hate speech content, "yes" will select only detected hate speech content
DEFAULT_FILTER_HATE_SPEECH_TOXIC_MODE=no
# (Optional. Default: 75. Options: 0-100) Default minimum probability/confidence score to determine the classification of hate speech (toxic comment)
DEFAULT_FILTER_HATE_SPEECH_TOXIC_CONFIDENCE=75
# (Optional. Default: max. Options: max, sum) Methods to determine toxic content by using max value from all toxic classes score or sum value of all toxic classes score
DEFAULT_FILTER_HATE_SPEECH_TOXIC_EVALUATION_MODE=max
# (Optional. Default: all, Multiple Options: all,negative,neutral,positive) Multiple options separated by comma (eg: neutral,positive => filter to get both neutral and positive sentiment)
DEFAULT_FILTER_SENTIMENT_MODE=all
# (Optional. Default: 35, Options: 0-100) Default minimum probability/confidence score in percentage to determine the classification of sentiment
DEFAULT_FILTER_SENTIMENT_CONFIDENCE=35
# (Default: all, Multiple Options: list of valid topic in atrifat/nostr-filter-relay Github) Multiple options separated by comma (eg: life,music,sport,science_and_technology => filter to get life (short version of: diaries_and_life), music, sport, science_and_technology)
DEFAULT_FILTER_TOPIC_MODE=all
# (Default: 35, Options: 0-100) Default minimum probability/confidence score in percentage to determine the classification of topic
DEFAULT_FILTER_TOPIC_CONFIDENCE=35
# (Optional. Default: all. Options: all, nostr, activitypub) Filter user type. "nostr" for native nostr users and "activitypub" for activitypub users coming from bridge
DEFAULT_FILTER_USER_MODE=all
And run using docker:
docker run --init --rm --env-file .env -p 7860:7860 -it ghcr.io/atrifat/nostr-filter-relay:v0.4.1
Is the problem still occur?
The nostr-filter seems to be having issues communicating with strfry if I'm understanding this correctly. Getting
Error: connect ECONNREFUSED 127.0.0.1:7777
in the nf.log when it first starts. In my config I set the detections to false and added hex pub/sec. In my reverse proxy logs, when initiating a query from nostr.info, Caddy says it got a "status":502 error.Tried setting ENABLE_FORWARD_REQ_HEADERS=true Also tried images do this for me except 0.3.0 doesn't give the econnrefused error, however requests still get 502.
Logs: