Coder Social home page Coder Social logo

Comments (11)

auxdevelopment avatar auxdevelopment commented on July 3, 2024

Does this error still persist for you with the newly added changes?

Also, did that just occur on Windows machines or could you experience the same issue on a different platform as well?

from fiskaly-kassensichv-client-java.

cjaentsch avatar cjaentsch commented on July 3, 2024

It feels like it happens less often right now, yet it still occurs in like 50% of the transactions. I haven't experienced this problem on MacOS.

from fiskaly-kassensichv-client-java.

auxdevelopment avatar auxdevelopment commented on July 3, 2024

I've tried to reproduce your error but failed unfortunately. This was the setup I've used:

OS: Windows 10
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

I've got some suspicions what could be causing the issue though:

  • Are the environment variables API_SECRET and API_KEY set and valid? Otherwise the client will fail with the error you've received.
  • Is it possible that the Windows machine sits behind a proxy that manipulates HTTP-Headers?

from fiskaly-kassensichv-client-java.

cjaentsch avatar cjaentsch commented on July 3, 2024

When I retry the transaction it works (sometimes). So it's not a general problem, but in some occasions. Maybe I have to notice that we do all requests via a "persistent" Java app / server, so the app is started once and then handles all request to fiskaly. We also only create the GeneralSMA object once (per server app start) and use it for all following requests. It that the valid type of use or should we create an instance of the GeneralSMA for every request again?

Nevertheless the exception sometimes already occurs at the first transaction after the server start (so with a "fresh" GeneralSMA object).

I could also implement an automatic retry if the exception is thrown. Today I'm not in the office, but I will report and then we can see if we can narrow down the problem.

from fiskaly-kassensichv-client-java.

cjaentsch avatar cjaentsch commented on July 3, 2024

Ok, so we tested it again. It happens randomly, but with 50% chance. I also tested to use a new instance of GeneralSMA for every request but that didn't work either, same behaviour.

Now we have implemented an automatic retry when this exception is thrown, so there is no impact anymore on our application. Nevertheless it's a weird thing.

from fiskaly-kassensichv-client-java.

auxdevelopment avatar auxdevelopment commented on July 3, 2024

That's especially weird because such a mechanism already exists. Are you sure you're using the latest version of the project?

You shouldn't need to create a new SMA instance for every request, one is sufficient.

from fiskaly-kassensichv-client-java.

cjaentsch avatar cjaentsch commented on July 3, 2024

Yes, we are up to date on master branch of the client. Yet I don't think that this issue is related to the 401 status when credentials are expired. This works as expected. The "Too many follow-up requests" is thrown when there are valid credentials given but some other things happening.

from fiskaly-kassensichv-client-java.

 avatar commented on July 3, 2024

I have the same issue on Android, it happens randomly:

java.net.ProtocolException: Too many follow-up requests: 21
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:122)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at com.fiskaly.kassensichv.client.interceptors.TransactionInterceptor.intercept(TransactionInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at com.fiskaly.kassensichv.client.interceptors.AuthenticationInterceptor.intercept(AuthenticationInterceptor.java:49)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at com.fiskaly.kassensichv.client.interceptors.HeaderInterceptor.intercept(HeaderInterceptor.java:23)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
at okhttp3.RealCall.execute(RealCall.kt:66)

    private static final String API = "https://kassensichv.io/api/v0";

    private static final ObjectMapper objectMapper = new ObjectMapper();
    private static final OkHttpClient okHttpClient = ClientFactory.getClient(Fiskaly.PUBLISHABLE_KEY, Fiskaly.SECRET_KEY, new AndroidSMA());

    private static void _createTss(final Context context) {
        try {
            // Request
            Map<String, String> body = new HashMap<>();
            body.put("state", "INITIALIZED");
            body.put("description", "test");

            Request request = new Request.Builder()
                    .url(Fiskaly.API + "/tss/" + UUID.randomUUID())
                    .put(RequestBody.create(Fiskaly.objectMapper.writeValueAsString(body), MediaType.parse("application/json")))
                    .build();

            // Response
            String response = Fiskaly.okHttpClient.newCall(request).execute().body().string();
            Log.i("APP_FISKALY", "TTS - " + response);

        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

I think it may come from the authentication.

from fiskaly-kassensichv-client-java.

auxdevelopment avatar auxdevelopment commented on July 3, 2024

Failed authentication will cause this behaviour. Did you verify that your credentials are valid for that example?

Regarding "it happens randomly": Does this means it works for some time but some requests randomly fail? If so, did you notice a particular group (e.g. targeting a specific resource) or type of requests failing or does that happen arbitrarily?

from fiskaly-kassensichv-client-java.

 avatar commented on July 3, 2024

I will try to collect more data the next time it happens.

from fiskaly-kassensichv-client-java.

prempador avatar prempador commented on July 3, 2024

This should be fixed with #30 .
I will close this issue for now but if, by any reason, this should happen again please just reopen the issue and come back to me.

from fiskaly-kassensichv-client-java.

Related Issues (16)

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.