I remember when I was younger I used to get really irked when the person I was with was greeted by every stranger that passed us but always ignored me, and I took it personally.
This was because one time I was with my mum and we both had our bikes. We were in an alley and an older woman was coming along in a wheelchair. I was in front of my mum, and I kindly moved aside to allow the disabled person to get by safely. I gave a friendly smile but she just glared at me as she passed. I shrugged it off, thinking she might just be that type of person. But when she passed my mum I heard her say hello to my mum. I assumed maybe my mum knew her, but when I asked if she did know her my mum said no. So it made me wonder why she would glare at me but be friendly to my mum when she didn't know her.
It seems that if you just meet someone's eye subconsciously you're more likely to get a hello from them than when you force yourself to look at them as you pass. Ordinarily I don't have a problem with making eye contact subconsciously, but when I'm walking along a street I suddenly become too aware of where I'm looking and suddenly forget how to make eye contact naturally when a stranger passes, because I'm focusing too much on thinking "oh, what do I do? When do I look at this person coming towards me? If I look at them it might make them self-conscious, if I don't look at them it might look like I've got something to hide, if I try and smile at them they might just glare at me like the disabled woman did then I'll get RSD, aarrgghh, what do I do?" The best way is to be focused on something else so that I'm not consciously thinking of how to be when passing a stranger, but that's easier said than done to consciously make yourself focus on something else.
That's why I feel more comfortable when I have a rat with me. When I went into a pharmacy with my rat in his pet carrier backpack (it has a window), I was focusing my thoughts on my rat and worrying that the pharmacist might boot me out if they saw my rat, and so because my thoughts were elsewhere I subconsciously met a woman's eye and automatically smiled, and she smiled back (she hadn't seen my rat, as I had just walked into the store and he was in my backpack).