Blockchain, Cryptocurrency & Smart Contracts
+34 518 880131

Blog

Official SigloTech Blog

  • Welcome, Guest!

By browsing this website you are agreeing to our use of cookies.

Posts tagged with “php”

“Empty reply from server” – Nginx, PHP, CURL

Recently we setup a sandbox server for one of our APIs. You know, it’s always a good idea to have customers play with a sandbox rather than with a production system. The setup went smoothly and the API did pass all the tests. However, one of our customers complained that when they were accessing the API via PHP they were getting “Empty reply from server”.

The Problem – Empty Response

What the heck, we thought and tried to replicate the problem. Exactly as the customer had reported, the API worked well from Postman and command line CURL but was failing with the PHP CURL big time. “Empty reply from server” was the exact error message.

We have an Nginx server sitting as a proxy in front of our application. A quick test revealed that the requests were not even reaching our API. So there was something in Nginx or in PHP.

A Strategy for Solving the Problem

Whenever we need to find a nasty bug in code or just want to solve a problem we always look at a working system and then try to spot a difference. But the irony is that our environments seemed to be exactly the same. Both the live and the sandbox servers run Debian Jessie 64 bit and we use the same version of Nginx.

One difference was that for the staging API we used a hyphen in the URL (to be more precise we used a sub-domain containing hyphen). After some Googling we came across a discussion saying that hyphens were not supported by CURL. It was a revelation. We quickly removed the hyphen from the sub-domain just to learn that it did have no effect. What a disappointment.

The Aha Moment

Finally we started comparing Nginx configurations. In our understanding this was the last point of hope. To our discouragement they looked exactly the same or did they? We were about to start screaming when we noticed a seemingly innocent difference between the configuration files. The production server had three lines of SSL configuration.

ssl_ciphers ECDH+AESGCM😃H+AESGCM:ECDH+AES256😃H+AES256:ECDH+AES128😃H+AES:ECDH+3DES😃H+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
ssl_session_cache shared:SSL:10m;
ssl_prefer_server_ciphers on;

So we quickly copied the SSL configuration lines to the sandbox and voila it all worked well. We hope this helps if you are stuck in a similar situation.

Tags: curl nginx php

Top Five Programming Languages To Learn

I often get asked by aspiring programmers (and more often by their parents) what programming languages they should learn. You may think that learning programming languages is a matter of taste. However, that’s very far from being true. I will bring just two arguments.

First, if you want to become a professional programmer and earn living by programming, you have to learn at least one programming language that is in great demand. Ideally, you should know two such languages.

Second, there are languages that are used for specific purposes. For example, even if you bring gazillion reasons why C++ is better than Javascript, one thing is undeniable. If you want to create front-end code that runs in browser you need to use Javascript.

In this article I will list top five languages that I think you should know. Moreover, I will provide rationale behind each choice. The order of the list is not very important.

C/C++

C has been around from early 1970s. It’s one of the most minimalist programming languages. If you do it right, code written in C is blazing-fast. This should not come as a surprise. C is very close to hardware, does not have checks and gives you so much freedom. Programs written in C will run everywhere from supercomputers to micro-controllers. For decades all attempts to replace C with other programming languages have failed. In early 2000s it was predicted that C would die. As far as C’s health is concerned it’s doing really well. C will be around for many years.

The same can be said about C’s big brother C++. C++ takes C to different heights. It’s a powerful, industrial-grade language. At lower levels, almost every software (operating systems, game engines, databases, even other programming languages, etc) are implemented in C or C++. Hence, if you want to have guaranteed and well paid job learn C/C++.

Personally I do not do much C++ programming but use C actively from hobby projects to commercial projects especially for IoT and robotics.

C# or Java

I’ve been programming C# since 2003, yeah almost 15 years. C# and Java are practically de-facto standards for enterprise programming. There are many reasons for this but the main reason is that both C# and Java are Internet/web oriented. At the same time, they are universal, support many programming paradigms and allow programming of practically everything. At the same time, they have good cross-platform capabilities (especially Java). Write once, run everywhere is indeed a great selling point for these languages. At the same time, both C# and Java developers are well paid and in constant demand.

Javascript or Typescript

Javascript is the world’s most popular programming (scripting) language. With the advent of server side Javascipt (yeah Node.js as you’ve probably heard) it has become truly ubiquitous. I have a love/hate relationship with Javascript because of its several idiosyncrasies. Though, it’s undeniable that if you learn Javascript you can do pretty much everything. If you plan to learn only one programming language, learn Javascript. You will be able to program everything from server-side to front-end and mobile. Though, I would recommend learning Typescript. Not only is Typescript more elegant and closer to a true programming language but it can also transpile into Javascript.

Python

Python is a cool scripting language. Python has very decent frameworks for web and fantastic support for machine learning. As machine learning has become a hot topic, so Python’s popularity is growing fast.

Go or Rust

Go or (Golang how it’s sometimes called) is a relatively new language created at Google. Go is a compiled, statically typed language. Go combines simplicity of C while providing memory safety and garbage collection. Go is much faster than C# and Java but not as fast as C. Though, where Go really shines is concurrency. I have not seen any other language where writing concurrent code is either as simple or pleasant as writing in Go. Go has a very decent standard library implementing all kinds of functionalities. At the same time Go has grown in popularity. Don’t like Go? Then you may look into Rust. It’s a system programming language from Mozilla foundation. Rust is also a statically typed and compiled language and you can write safe code that also runs fast.

Functional and Exotic Languages

I know the title of the post says top five languages. But I find it very useful to learn at least one functional and one relatively exotic language. For functional languages you may learn Haskel or F#. If you are in math then you will find Haskel really cool.

Final Thoughts

Of course there are hundreds of programming languages out there. Not all of them are popular. Many have died. Yet, there are many popular languages that I have not listed. For example PHP. I program in PHP from time to time. Though if you know C# or Java or Python then PHP becomes really redundant. Don’t want to learn Python? Then you may replace it with PHP.

What about Perl? Perl is an excellent language and as a matter of fact I started web programming in Perl. Perl is also out of competition when it comes to text processing and Regular Expressions. What about Prolog, Lisp, Erlang, Ada? They are fantastic languages but of course they are not mainstream. Maybe your dream is to work for defense and aeronautics? Then learning Ada is a really nice idea. Well you get the point.

Finally, I would say that try as many programming languages as you can and then stick to those you really love. You will be spending days, months and years expressing yourself in languages of your choice.

Tags: c c go java javascript php programming-languages python rust typescript
About SigloTech

SigloTech is a software development and consulting company with a primary focus on Blockchain, Cryptocurrency and Smart Contracts.

Contact Details
Subscribe

Your privacy is our top priority!

©2018 SigloTech. All rights reserved.