Code Monkey home page Code Monkey logo

Comments (6)

jchambers avatar jchambers commented on June 16, 2024

This error is displayed when I send consecutively

I'm not totally sure I understand what you mean. Do you mean that you send one push notification successfully, then try to send another and the second notification fails?

I tried to check for packet conflicts, but it didn't work

I'm really sorry, but I don't know what you mean by "packet conflicts." Do you mean TCP packet retransmissions?

Let's take a step back, though: does this happen every time you try to send a notification? Can you tell us more about your setup? Are you using a proxy, for example?

from pushy.

spland avatar spland commented on June 16, 2024

Sorry, I may not have made it clear. In a concurrent environment, the same client is used to send, for example, I sent more than a dozen messages at the same time, and then this problem occurred

from pushy.

spland avatar spland commented on June 16, 2024

I'm not totally sure I understand what you mean. Do you mean that you send one push notification successfully, then try to send another and the second notification fails?

I tried to check for packet conflicts, but it didn't work

I'm really sorry, but I don't know what you mean by "packet conflicts." Do you mean TCP packet retransmissions?

Let's take a step back, though: does this happen every time you try to send a notification? Can you tell us more about your setup? Are you using a proxy, for example?

yes, proxy is used

from pushy.

spland avatar spland commented on June 16, 2024
public static  ApnsClient getApnsClient() throws NoSuchAlgorithmException{
        if (apnsClient == null) {
            byte[] bytes = decodeBase64EncodedString(privateKey);

            final PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(bytes);
            final KeyFactory keyFactory = KeyFactory.getInstance("EC");
            ECPrivateKey signingKey;
            try {
                signingKey = (ECPrivateKey)keyFactory.generatePrivate(keySpec);
                ApnsSigningKey signing = new ApnsSigningKey(keyId, teamId, signingKey);
                signing.getEncoded();
                apnsClient = new ApnsClientBuilder().setApnsServer(ApnsClientBuilder.PRODUCTION_APNS_HOST)
                    .setProxyHandlerFactory(new HttpProxyHandlerFactory(new InetSocketAddress(proxyAddress, port)))
                    .setSigningKey(signing).setConcurrentConnections(4)
                    .build();
            } catch (Exception e) {
                LogUtils.error("apns push create exception",null,e);
            }
        }
        return apnsClient;
    }

This is the client I created, is it created incorrectly ?I created it based on token, not in the way of .p12

from pushy.

spland avatar spland commented on June 16, 2024
PushNotificationFuture<SimpleApnsPushNotification, PushNotificationResponse<SimpleApnsPushNotification>>
            future = apnsClient.sendNotification(simpleApnsPushNotification);
            future.whenComplete((pushNotificationResponse,cause)->{
                if (pushNotificationResponse != null) {
                    if (pushNotificationResponse.isAccepted()) {
                        LogUtils.info("Push notification accepted by APNs gateway.", request);
                        BuyerMessagePushSchedule.buyerAppleSuccessPushCounter.incrementAndGet();
                    } else {
                        String errorReason = pushNotificationResponse.getRejectionReason().toString();
                        if (errorReason.contains("BadDeviceToken") || errorReason.contains("Unregistered")) {
                            userDeviceService.setInvalidStatus(request.getfUserDeviceId());
                        }
                        BuyerMessagePushSchedule.buyerAppleFailurePushCounter.incrementAndGet();
                        LogUtils.error("push apns error", errorReason, null);
                    }
                    
                } else {
                    LogUtils.error("push apns exception cause",cause.getMessage());
                    
                }
            });

This is how I use

from pushy.

spland avatar spland commented on June 16, 2024

I found the same problem in issues #829

from pushy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.