Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught error when writing to nostr.wine #77

Open
SilberWitch opened this issue Jan 3, 2025 · 8 comments
Open

Uncaught error when writing to nostr.wine #77

SilberWitch opened this issue Jan 3, 2025 · 8 comments

Comments

@SilberWitch
Copy link

Hi, I was testing writing 30040 events to various relays, and it worked everywhere except nostr.wine. Mazin says that the kind isn't blocked, and my user has wine access.

When I look at what it's doing, it receives the ping and apparently no ERROR, but it must be getting something wrong back. Could you test it out, for me, with your own npub? Is it something with the AUTH?

PHP Warning: Undefined variable $result in /home/ohji/Projects/eBookUtility/vendor/swentel/nostr-php/src/Relay/RelaySet.php on line 143

@Sebastix
Copy link
Member

Sebastix commented Jan 4, 2025

https://github.com/nostrver-se/nostr-php/releases/tag/1.5.3

A Pong message is now send back to the relay when a Ping message was received. I think that's the problem that was needed to be fixed.

I also added this snippet src/Examples/publish-event-with-auth.php

<?php

declare(strict_types=1);

require __DIR__ . '/../../vendor/autoload.php';

use swentel\nostr\Event\Event;
use swentel\nostr\Key\Key;
use swentel\nostr\Message\EventMessage;
use swentel\nostr\Relay\Relay;
use swentel\nostr\RelayResponse\RelayResponse;
use swentel\nostr\RelayResponse\RelayResponseOk;
use swentel\nostr\Request\Request;
use swentel\nostr\Sign\Sign;

try {
    $note = new Event();
    $note->setKind(1);
    $note->addTag(['t', 'introduction']);
    $note->addTag(['r', 'wss://nostr.wine']);
    $content = 'Hello Nostr world! This is just a test, please ignore.';
    $note->setContent($content);
    // Sign event.
    $private_key = new Key();
    $private_key = $private_key->generatePrivateKey();
    $signer = new Sign();
    $signer->signEvent($note, $private_key);
    // Optional, verify event.
    $isValid = $note->verify();
    // Transmit the event to a relay.
    $relay = new Relay('wss://nostr.wine');
    $eventMessage = new EventMessage($note);
    $relay->setMessage($eventMessage);
    $request = new Request($relay, $eventMessage);
    $response = $request->send();
    // Handle response.
    foreach ($response as $relayUrl => $relayResponses) {
        foreach ($relayResponses as $relayResponse) {
            if ($relayResponse->isSuccess && $relayResponse instanceof RelayResponseOk) {
                print 'The event has been transmitted to the relay ' . $relayUrl . PHP_EOL;
                $eventId = $relayResponse->eventId;
                print 'The received event id from the relay: ' . $relayResponse->eventId;
                // Now we could request the event with this id.
            }
        }
    }
} catch (Exception $e) {
    print 'Exception error: ' . $e->getMessage() . PHP_EOL;
}

@SilberWitch please let me know if this is solving your issue :)

@SilberWitch
Copy link
Author

Sorry, that I didn't reply sooner.

I now just get "Connection error" as a response.

@Sebastix
Copy link
Member

Sebastix commented Jan 9, 2025

Also with the example snippet provided in the library?

@SilberWitch
Copy link
Author

I'm sorry, but which snippet do you mean?

@Sebastix
Copy link
Member

Sebastix commented Jan 9, 2025

I'm sorry, but which snippet do you mean?

https://github.com/nostrver-se/nostr-php/blob/main/src/Examples/publish-event-with-auth.php

@SilberWitch
Copy link
Author

No, I now get Exception error: Connection error

It might be a problem with my DNS, tho. We're going to install a new router and then I'll try again.

@SilberWitch
Copy link
Author

Still doesn't work. See PR.

@Sebastix
Copy link
Member

This will be solved in a next release of the sirn-se/websocket-php package (see sirn-se/websocket-php#100 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants